Loop for matrix summation
Mostrar comentarios más antiguos
Hello, sorry if my question is stupid, I am a beginner in matlab
I would like to do a 3*3 matrix sumation (element by element). More in detail: I am working with a matlab fuction which output is a 3*3 matrix, the input is 3 column data (strr1,dpr1and rkr1). Then I would like to divide each matrix obtained from the input (280 elements, so I have 280 3*3 matrix) by a scalar, and finally, from that result I would like to sume each matrix to get a single 3*3 matrix (the result of the summation of all matrix calculated by the function). Next, a small script about my problem
Thanks for your attention
strr1=(tw1r1(:,12)); %%input1
dpr1=(tw1r1(:,14)); %%input2
rkr1=(tw1r1(:,16)); %%input3
mtr11w1s=zeros(3,3) %% I created this matriw for storing the final summation
for rr1=1:length(strr1) %%% loop for calculating the 280 3*3 matrix from thre 3 inputs
mtr1=SDR2MT(strr1( rr1),dpr1( rr1),rkr1( rr1)) %%%% Result: 280 3*3 matrix
mtr1n=mtr1/length(tw1r1) %%%%Escalar division for each element of the 3*3 matrix
for z=1:length(mtr1n) %%%% Here I try to do a loop for doing the summation of 280 3*3 matrix
mtr11w1s= mtr11w1s+mtr1n(z)
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!