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

조회 수: 3 (최근 30일)
chan
chan 2021년 10월 26일
댓글: chan 2021년 10월 26일
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
hamza karim
hamza karim 2021년 10월 26일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by