필터 지우기
필터 지우기

Hi, does anyone know how to stop my for loop overwriting? I need my answer to be a matrix with each element being a 2x2 matrix also.

조회 수: 1 (최근 30일)
[M,N] = size(MagGridForceAX); % Establish dimensions for row and column loop counters
for i = 1:M
for j = 1:N
% Creates coefficients for the simultaneous equations of F1 and F2
% based on sum of x and sum of y forces equalling zero
CoefficientMatrix = [MagGridForceAX(i,j) MagGridForceBX(i,j); MagGridForceAY(i,j) MagGridForceBY(i,j)]
% Forces Matrix solving for forces in beams in each x and y
% coordinate
ForcesMatrix = CoefficientMatrix\P;
end
end

답변 (1개)

Walter Roberson
Walter Roberson 2022년 9월 17일
ForcesMatrix{i, j} = CoefficientMatrix\P;
The result will be a cell array that contains numeric arrays.
You could also do
ForcesMatrix(:, :, i, j) = CoefficientMatrix\P;
The result would be a 2 x 2 x M x N numeric array.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by