フィルターのクリア

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 Center および File ExchangeLoops 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