for loop to get results for each iteration
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to figure out how to get my for loop to get values for each iteration I'm running but it's only giving me the results for the final iteration (column six). What should I do?
Eedmat=[10 11 12 13 14 15]
Eh2dmat=[5 6 7 8 9 10]
Eheatdmat=[4 5 6 7 8 9]
for n=1:6
Eed=Eedmat(n)
Eh2d=Eh2dmat(n)
Eheatd=Eheatdmat(n)
end
Etotal=Eed+Eh2d+Eheatd
M(:,1)=Eetot
M(:,2)
%.....
%.....
%..... Continue..
%.....
M(:,6)=Eetot
0 comentarios
Respuestas (1)
Star Strider
el 17 de Jun. de 2019
Your loop is not doing anything except copying your original vectors to new vectors.
Try something like this instead:
Eedmat=[10 11 12 13 14 15];
Eh2dmat=[5 6 7 8 9 10];
Eheatdmat=[4 5 6 7 8 9];
Emtx = [Eedmat; Eh2dmat; Eheatdmat]; % Vertically Concatenate
Etotal = sum(Emtx);
M = Etotal;
Even then, ‘M’ is a copy of ‘Etotal’.
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!