Can't generate histfit subplot (error using histfit, subscripting into a table)
7 views (last 30 days)
Show older comments
Austin Davis
on 20 Sep 2022
Commented: Star Strider
on 21 Sep 2022
My goal is to create a series of subplots of normalized histograms using an existing data table. I am working with the function histfit.
After the master data table has been loaded in, I partition the data based on columns and other categories individually, and make a new table with this information. For example.
Stained_FSCH = MasterSheet(1552:82500,1)
This Stained_FSCH specifies column 1 of the table from rows 1552 through 82500 should represent this parameter. To my knowledge, I have been specific.
When I try to run this code as instructed (for the sake of simplicity at this time and resolving this issue, I ran
histfit(Stained_FSCH)
I am met with the error . Notably, checking line 69 in any of the tables does not reveal anything unordinary, and this persists even if I run the code in a new session and matlab file without 69 lines as well
Error using histfit (line 69)
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable subscript, as in
t(rows,vars). To select variables, use t(:,i) or for one variable t.(i). To select rows, use t(i,:).
What changes do I, specifically, need to implement here? I do not think I am understanding why I am getting an error.
Thank you.
0 Comments
Accepted Answer
Star Strider
on 21 Sep 2022
The error is in the histfit code at line 69. That reference has nothing to do with your code or data.
The problem is likely that you are giving histfit a table as an argument. According to the histfit documentation section on data, it needs to be an array, not a table. Use the table2array function first, and histfit will likely have no problems with it.
This:
histfit(table2array(Stained_FSCH))
may run without error. (I obviously can’t test this with your data.)
3 Comments
Walter Roberson
on 21 Sep 2022
Or instead,
Stained_FSCH = MasterSheet{1552:82500,1};
Star Strider
on 21 Sep 2022
@Austin Davis — My pleasure!
If my Answer helped you solve your problem, please Accept it!
@Walter Roberson — Thank you. I thought of that too, however I opted for table2array for simplicity.
.
More Answers (0)
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!