Replacing Matirx after each loop

조회 수: 2 (최근 30일)
A
A 2021년 1월 27일
댓글: A 2021년 2월 2일
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?

채택된 답변

Shashank Gupta
Shashank Gupta 2021년 2월 2일
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.
  댓글 수: 1
A
A 2021년 2월 2일
Hi,
Thank you so much it did help

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by