Can't generate histfit subplot (error using histfit, subscripting into a table)
조회 수: 4 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2022년 9월 21일
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
Walter Roberson
2022년 9월 21일
Or instead,
Stained_FSCH = MasterSheet{1552:82500,1};
Star Strider
2022년 9월 21일
@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.
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!