how to store the values in a matrix every time within an infinite while loop

2 Ansichten (letzte 30 Tage)
chan
chan am 26 Okt. 2021
Kommentiert: chan am 26 Okt. 2021
reply_timer=5;
t=20;
The infinte loop will run 15 times(t-reply_timer). Everytime when the loop got executed we get some value. How to store all this 15 values updated in a matrix.???? Could anyone suggest me some hints??
while(1)
if(reply_timer<t)
......
........
Value= max(S(:));// some calculation done to find Value
end
end
  2 Kommentare
hamza karim
hamza karim am 26 Okt. 2021
if the infinite loop will run 15 times, i would understand that at the end you would have a total of 15 values, where each value is a scalar since you write "value=max(S(:)". In this case, i assume your S is a vector of nx1 and then Value is a scalar.
I would simple define value before the while loop as a vector of size 15 and put a counter that woul update after each iteration
Value=zeros(15,1);
counter=1;
while (1)
if(reply_timer<t)
value(counter)=max(S(:));
end
counter=counter+1;
end

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by