フィルターのクリア

Fill an array over an iteration

1 回表示 (過去 30 日間)
luca
luca 2019 年 9 月 10 日
回答済み: the cyclist 2019 年 9 月 10 日
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 Center および File ExchangeLoops 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