Fill an array over an iteration

4 次查看(过去 30 天)
Given the following code
D= [1 2 3 ; 4 5 6 ]
for i= 1: size(D,1)
M = [4 2 4 3 2; 2 1 3 1 2; 4 1 2 3 1];
r= size(M,1)
c=size(M,2)
Tc=cumsum(M)
T=cumsum(Tc,2)
%T= [4 6 10 13 15; 6 0 0 0 0 ; 10 0 0 0 0]
for j= 2:size(T,1)
for k= 2:size(T,2)
T(j,k)=max(T(j,k-1)+M(j,k),T(j-1,k)+M(j,k))
end
end
rowNum = find(any(T >18,2),1,'first');
B=D(i,:);
Dstop=B(1:rowNum-1)
BBB(i,:)=B(:) %% HERE THE PROBLEM
end
I have a problem in the penultime row, where I want to fill the vector BBB with the value Dstop that I obtain at each cycle
does someone may help me?

采纳的回答

the cyclist
the cyclist 2019-9-10
Does using
BBB(i,:)=Dstop
instead of
BBB(i,:)=B(:)
do what you want?
If not, you need to explain a bit more.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by