while loop in data file for trapz?
1 view (last 30 days)
Show older comments
I have an array (read in from a data file) and I'm trying to integrate a series of values in one column. The problem is that sometimes there are 6, 7, or 8 values in the series to integrate. These, however, are defined by a 'Number' at the beginning of each row. So, it seems: while Number == some value, then I can identify the range of values over which to do the integration. But matlab doesn't recognize any variables inside the loop. Even
A = [Num X Y Z];
while Num == 1
disp(Num)
end
doesn't work. Any help?
0 Comments
Answers (1)
Ahmed A. Selman
on 14 Apr 2013
Apparently, the variable (Num) is not (1). That's why the (while loop) returns nothing. I've tried the lines you posted and it works when Num==1, perfectly. So perhaps you meant to code:
A = [Num X Y Z];
while Num ~= 1 % Works when Num equals NOT 1
disp(Num)
end
.. or perhaps you meant
while A(1)==1
?? Also keep in mind that the while loop such as the one programmed above will never stop by itself, unless there is some calculation inside the loop that changes the value of Num.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!