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

5 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Analysis of Variance and Covariance 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by