Fill an array over an iteration

2 visualizaciones (últimos 30 días)
luca
luca el 10 de Sept. de 2019
Respondida: the cyclist el 10 de Sept. de 2019
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?

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by