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

4 ビュー (過去 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 Center および File ExchangeAnalysis 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