How can one get parameters of fitlm as an output? Part 2
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponse acceptée
Ameer Hamza
le 2 Déc 2020
Modifié(e) : Ameer Hamza
le 2 Déc 2020
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Generate Report dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!