Trying to assign names to output values of 10x10

1 view (last 30 days)
So I am working on a truss problem where I end up with 10x10 matrix. After solving, I get only values in the output. But I’m trying to assign name of the forces (i.e A_x, B_x etc) to the values.
How can I do that?

Answers (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 26 Sep 2021
Should I understood your question correctly, you want to assign variable names for your computation output values. If so, that is very straightforward, e.g.:
...
% Output is:
OUT = ....
Ax = OUT(1,1); Bx = OUT(2,1); ...

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 26 Sep 2021
It can be done this way, e.g.:
OUT = rand(5,1);
for ii = 1:numel(OUT)
fprintf('Ax(%d) = %f \n', [ii, OUT(ii)])
end
Ax(1) = 0.247124 Ax(2) = 0.224384 Ax(3) = 0.381448 Ax(4) = 0.661216 Ax(5) = 0.821635
%% OR
OUT = rand(5,1);
fprintf('Ax = %f \n', OUT(1))
Ax = 0.825961
fprintf('Bx = %f \n', OUT(2))
Bx = 0.698033
fprintf('Cx = %f \n', OUT(3))
Cx = 0.033715
...

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!