Add n by n matrix that is in a for loop and get the same size

조회 수: 1 (최근 30일)
Ivon Flores
Ivon Flores 2020년 4월 23일
댓글: Ivon Flores 2020년 4월 23일
I have a matrix A that depends on different conditons. I was able to get the output of the diffrent A matrix by calling A(n) now i want to get the result of each A matrix and add them. Since the variable is the same name I keep getting a different size matrix but I want to add the different values of A to get one matrix of the same size.
A = Z_bar* thickness % for different Z values i get a different A
so i should essentially add A+A+A but for the different values generated to get one matrix A_total
for my example the matrix is a 3x3 matrix

채택된 답변

David Hill
David Hill 2020년 4월 23일
Just add a dimension to A, then:
A(:,:,1)= %3x3 matrix
A(:,:,2)= %3x3 matrix ...
sumA=sum(A,3);
  댓글 수: 3
David Hill
David Hill 2020년 4월 23일
for n = 1:3
A(:,:,n) = Z_bar* thickness;
end
sumA=sum(A,3);
Ivon Flores
Ivon Flores 2020년 4월 23일
thank thank thank youuu!!!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by