필터 지우기
필터 지우기

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 CenterFile Exchange에서 Instrument 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