How can one get parameters of fitlm as an output? Part 2

조회 수: 11 (최근 30일)
alpedhuez
alpedhuez 2020년 12월 2일
댓글: alpedhuez 2020년 12월 2일
I learned how to get a table variable of 'table'= "ANOVA summary statistics table."
I now want to extract an element and got 1*1 table.
How can one convert 1*1 table to string?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 2일
편집: Ameer Hamza 2020년 12월 2일
avova() returns a table object. You need to access its value like any normal table: https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.html
For example, consider this code from the documentation page of avova:
load hospital
tbl = table(hospital.Age,hospital.Sex,hospital.BloodPressure(:,2), ...
'VariableNames',{'Age','Sex','BloodPressure'});
tbl.Sex = categorical(tbl.Sex);
mdl = fitlm(tbl,'BloodPressure ~ Sex + Age^2')
tbl = anova(mdl)
Result
>> tbl
tbl =
4×5 table
SumSq DF MeanSq F pValue
______ __ ______ _______ ________
Age 18.705 1 18.705 0.40055 0.52831
Sex 222.09 1 222.09 4.7558 0.031643
Age^2 30.934 1 30.934 0.66242 0.41772
Error 4483.1 96 46.699
You can access values like this
>> tbl.pValue(4)
ans =
0.5000
>> tbl{1,1}
ans =
18.7052
>> tbl{3,2}
ans =
1
>> tbl{2,5}
ans =
0.0316
or
>> tbl.SumSq(1)
ans =
18.7052
>> tbl.DF(3)
ans =
1
>> tbl.pValue(2)
ans =
0.0316
  댓글 수: 1
alpedhuez
alpedhuez 2020년 12월 2일
Yes but the output is 1*1 table that was not easy to deal.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Generate Report에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by