For Loop No Idea!
Mostrar comentarios más antiguos
So I'm not used to how you write programming code in Matlab, or really any language to be honest, so could someone tell me how to make this for loop work
for start = 1:VgStep:endPoint-VgStep
for step = VgStep:VgStep:endPoint
x1 = x(start:step);
y1 = y(start:step);
end
end
I think you can probably get the general idea of what I would like it to do..
6 comentarios
Albert Yam
el 30 de Jul. de 2012
The loop you are writing is looking for the vector 'x', elements from 'start' to 'step', and putting that into x1 (and same for y1). Are you sure that is what you want to do?
Ryan
el 30 de Jul. de 2012
All I got out of that is that you are trying to save some variables in a loop:
Try explaining your problem or goals instead of placing code that you don't understand enough to even ask a question about it.
What information are you trying to get from x and y using these start and step terms? Currently through the loop you are saving over x1 and y1 each time with the values in vectors x and y with the values of those vectors between your current values of start and step (the start:step) - did you want that?
Walter Roberson
el 30 de Jul. de 2012
The loop as written is overwriting x1 and y1 on each iteration of the two loops.
What is your desired output?
Adam Parry
el 30 de Jul. de 2012
Editada: Adam Parry
el 30 de Jul. de 2012
Adam Parry
el 30 de Jul. de 2012
Walter Roberson
el 30 de Jul. de 2012
return will likely not help.
"break" might possibly help, perhaps.
Respuestas (2)
Adam Parry
el 31 de Jul. de 2012
2 comentarios
Adam Parry
el 31 de Jul. de 2012
Editada: Adam Parry
el 31 de Jul. de 2012
Adam Parry
el 31 de Jul. de 2012
Categorías
Más información sobre Structures en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!