Borrar filtros
Borrar filtros

Get a new matrix from another matrix through loop

1 visualización (últimos 30 días)
Elizabeth Yeap
Elizabeth Yeap el 6 de En. de 2021
Respondida: KSSV el 6 de En. de 2021
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

Respuesta aceptada

KSSV
KSSV el 6 de En. de 2021
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

Más respuestas (0)

Categorías

Más información sobre Instrument Control Toolbox Supported Hardware en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by