Filter löschen
Filter löschen

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 Ansicht (letzte 30 Tage)
[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

Antworten (1)

Walter Roberson
Walter Roberson am 17 Sep. 2022
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.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by