フィルターのクリア

Get a new matrix from another matrix through loop

1 回表示 (過去 30 日間)
Elizabeth Yeap
Elizabeth Yeap 2021 年 1 月 6 日
回答済み: KSSV 2021 年 1 月 6 日
Dear all,
I want to obtain matrix D_GW from D_AQ where:
D_GW = [a b c; d e f];
D_AQ = [(b-a) (c-b); (e-d) (f-e)];
To do this, I have set the initial column of D_GW as 0 and simply add D_AQ but I keep getting the error "Index in position 1 exceeds array bounds (must not exceed 1)". Any help is greatly appreciated. Thank you.
D_GW = [];
D_GW(:,1) = 0;
D_AQ = [2 3; 5 6]; % D_GW = [0 2 5; 0 5 11]
for row = 1:size(D_AQ,1)
for col = 1:size(D_AQ,2)
D_GW(row,col+1) = D_GW(row,col) + D_AQ(row,col);
end
end

採用された回答

KSSV
KSSV 2021 年 1 月 6 日
D_GW = zeros(2,3);
D_GW(:,1) = 0;
D_AQ = [2 3; 5 6]; % D_GW = [0 2 5; 0 5 11]
for row = 1:size(D_AQ,1)
for col = 1:size(D_AQ,2)
D_GW(row,col+1) = D_GW(row,col) + D_AQ(row,col);
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInstrument Control Toolbox Supported Hardware についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by