iterate names for LinearModel fit Objects

5 Ansichten (letzte 30 Tage)
Edward Byers
Edward Byers am 19 Jul. 2016
Beantwortet: Edward Byers am 19 Jul. 2016
I need to iterate through a large number of LinearModel fit Objects and have them stored in a logical way, preferably through an indexing method, e.g. model{x,y}. Less preferable is eval(), which I have tried and in any case is not working. I get the error Index exceeds matrix dimensions.
"Index exceeds matrix dimensions." - although the string expression works just fine outside of eval.
counter = 48;
str=strcat('model',+num2str(counter)); % Dynamic variable name
str1 = strcat(str,'=fitlm(tbl,modelspec)');
eval(str1)
Ideally I wanted to do, while iterating through x
model{x,y} = fitlm(tbl,modelspec)
But the error I get is
"Assignment using {} is not allowed for a FitObject."

Akzeptierte Antwort

Edward Byers
Edward Byers am 19 Jul. 2016
Managed to fix this by assigning a cell structure
model = cell(3,3) % Pre-assign a cell structure
for x=1:3
for y=1:3
model{x,y} = fitlm(tbl,modelspec);
end
end

Weitere Antworten (0)

Kategorien

Mehr zu Construction finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by