save result in while loop

7 Ansichten (letzte 30 Tage)
NA
NA am 18 Mär. 2019
Bearbeitet: NA am 18 Mär. 2019
I have a this code
index_A=[];
while (ibd <= max_it)
i=i+1;
index_A =[tt;index_A]
end
in i=1; index_A=[19;20].
in i=2; index_A=[14].
how I can save them all in index_A?
result should be=[19;20;14];
index_A(i) =[tt;index_A]
the above code is not working
  2 Kommentare
madhan ravi
madhan ravi am 18 Mär. 2019
what's tt and why do you need a loop?
NA
NA am 18 Mär. 2019
I have random variable in the loop
tto=find(mes>5);
TT=[tto;TT];
so TT is changing.
TT=[];
index_A=cell([],1);
while (ibd <= max_it)
i=i+1;
tto=find(mes>5);
TT=[tto;TT];
index_A = find( some condition);
index_A{i}= tt ;% save what you want ;
end
index_A = cell2mat(index_A) ;

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KSSV
KSSV am 18 Mär. 2019
index_A=cell([],1);
while (ibd <= max_it)
i=i+1;
index_A{i}= t ;% save what you want ;
end
index_A = cell2mat(index_A) ;
  3 Kommentare
KSSV
KSSV am 18 Mär. 2019
index_A{i} =tt ;
KSSV
KSSV am 18 Mär. 2019
We cannot help unless the whole code is shown.

Melden Sie sich an, um zu kommentieren.

Kategorien

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