How can i loop through certain columns in matrix, for example, 3th, 5th, 6th and 7th column?
Afficher commentaires plus anciens
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);
Réponses (1)
Geoff Hayes
le 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 commentaire
NjZ
le 22 Nov 2018
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!