Replacing Matirx after each loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
suppose i have matrix A
and i do this:
A=[13 4 6; 3 6 7;2 3 5];
then i set matrices
B=[]
C=[]
and I set the highest A(1,:) value to B matirx
after doing some conditions i end up with
A=[]
B=[13 4 6; 2 3 5]
C=[3 6 7]
how would i make the B matirx the new A matirx and repeat whole process, including setting the max point again?
Would it be
A=[13 4 6; 3 6 7;2 3 5];
B=[]
C=[]
[b0,i]=max(A(1))
B(1,:)=A(i,:)
for i=1:A.length()
:
Some conditions
then A=B
end
Would that be right or doing it some other way?
0 Kommentare
Akzeptierte Antwort
Shashank Gupta
am 2 Feb. 2021
Hi,
I don't quite follow the operations you are performing, but here is the general template of such problems. It looks like a iterative problem.
% define variables
A = % define the initial A.
B=[];
C=[];
% A loop to iterate
Loop
% Do your thing here.
% update the A to B
A = B;
end
Or you can also put all these inside a function and call it multiple times. It will be more convenient and structured.
I hope this helps.
Cheers.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Industrial Statistics 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!