Replacing Matirx after each loop
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Industrial Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!