Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Nested for loops help!

2 visualizaciones (últimos 30 días)
Andrew Wiebe
Andrew Wiebe el 23 de Sept. de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
If i have
m1(n,1)=(m2(n,1)+((m3(n,1))*p));
Where m1 m2 and m3 are all arrays. if i wanted the range of n=1:42, and the range of p=1:31, how could i tell matlab to calculate l=1:31 for every different value of n?

Respuestas (2)

BAN
BAN el 24 de Sept. de 2015
Editada: James Tursa el 24 de Sept. de 2015
Try using this:
for n = 1:42
for p=1:31
m1(n,1)=(m2(n,1)+((m3(n,1))*p));
end
end
Here, for every value of n, that equation will be executed 31 times.
Hope it helps !!

Andrew Wiebe
Andrew Wiebe el 24 de Sept. de 2015
Ok i think it worked, just confused because it lists the name of each element within n as the values, and i expected them to be called 31x1 double for something similar.

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by