Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
[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

Respuestas (1)

Walter Roberson
Walter Roberson el 17 de Sept. de 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.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by