How to save multiple 3x1 matrixes in one big matrix?

7 views (last 30 days)
I have this code so far
for F = 100:500
A = [2/7, -1.5/6.5, -1/3; 3/7, 2/6.5, -2/3; -6/7, -6/6.5, -2/3];
B = [0; 0; -F];
X = A\B;
end
And I get a 3x1 matrix for X and I was trying to figure out how to save all the values into one big 3x400 matrix but can't figure it out any help would be appreciated.

Accepted Answer

Dave B
Dave B on 11 Oct 2021
How about:
f = 100:500;
X = nan(length(f),3);
A = [2/7, -1.5/6.5, -1/3; 3/7, 2/6.5, -2/3; -6/7, -6/6.5, -2/3];
for i = 1:length(f)
F = f(i);
B = [0; 0; -F];
X(i,:) = A\B;
end
X
X = 401×3
66.0377 12.2642 48.1132 66.6981 12.3868 48.5943 67.3585 12.5094 49.0755 68.0189 12.6321 49.5566 68.6792 12.7547 50.0377 69.3396 12.8774 50.5189 70.0000 13.0000 51.0000 70.6604 13.1226 51.4811 71.3208 13.2453 51.9623 71.9811 13.3679 52.4434

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!