Filter löschen
Filter löschen

Print out values in a while loop each time into an array.

1 Ansicht (letzte 30 Tage)
JE am 16 Okt. 2015
Kommentiert: Ken Atwell am 16 Okt. 2015
I want this while loop to print out the endlocation each time into an array. How do I do this?
while startcounter<7088
while start{1,1}(startcounter)>stop{1,1}(endcounter);

Antworten (1)

Ken Atwell
Ken Atwell am 16 Okt. 2015
A semicolon at the end of the line suppresses output [ reference ], so displaying output is a matter of just remove the semicolon from your existing statement:
If you want to print out the value of endlocation in the inner loop, just remove the semi-colon:
If you want to print out the value in the outer loop, add a new line with just the variable name (and no semi-colon) where/when you want it displayed.
  2 Kommentare
JE am 16 Okt. 2015
So this is the number that it displays, however, I thought it would display each location inside the array every time and place those values into a new array. Am I missing something?
Ken Atwell
Ken Atwell am 16 Okt. 2015
The entire array will be displayed, but endlocation looks to a scalar (non-array) value.
If you're trying to debug this, I recommend settings a breakpoint and single-stepping through this loop. Keep you eyes on the Workspace windows and look for unexpected values.

Melden Sie sich an, um zu kommentieren.


Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by