How can i loop through certain columns in matrix, for example, 3th, 5th, 6th and 7th column?
Ältere Kommentare anzeigen
for i = 3 : [5 6 7]
M = fitlm(trening(:,[2 4 i]),trening(:,1),'linear');
e3(i) = M.SSE;
end
e3 = e3(3 : [5 6 7]);
e3 = min(e3);
Antworten (1)
Geoff Hayes
am 22 Nov. 2018
Try using
for k = [3 5 6 7]
M = fitlm(trening(:,[2 4 k]),trening(:,1),'linear');
e3(k) = M.SSE;
end
Though be aware that you will be updating the same columns (3,5,6,7) in e3 when you may be wanting to update the first four columns.
1 Kommentar
NjZ
am 22 Nov. 2018
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!