# Replacing Matirx after each loop

2 vues (au cours des 30 derniers jours)
A le 27 Jan 2021
Commenté : A le 2 Fév 2021
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Shashank Gupta le 2 Fév 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
% 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.
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
A le 2 Fév 2021
Hi,
Thank you so much it did help

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Subplots dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by