How do I get variables in one matrix to equal values of another matrix of the same size?
2 views (last 30 days)
Show older comments
So this is my code and results:
[E,a] = equationsToMatrix(X);
A = linsolve(E,a)
B = reshape(symvar(X),9,1)
A =
27.259612093685907239924765633404
27.226801647240281533300016583626
26.274987496895494385896860482583
38.886877574000088205516622461231
38.714347945979799543030104724422
37.330809329818070922123744245312
89.059822722471622442231953601839
80.477118948255316513256261422728
75.235436854221051941898661779481
B =
T1
T2
T3
T4
T5
T6
T7
T8
T9
How would I get the variables in B to equal the values in A? I know I can do T1 = A(1) and so on, but im looking for a more efficeint way of doing this. Im kinda new to MATLAB so im trying to learn online. Im sure this has been posted before but I couldnt figure out the wording. Any help will be much appreciated!
0 Comments
Accepted Answer
David Hill
on 22 Apr 2020
You don't need a new variable. Any time you want to use T1, just write A(1), T2, A(2), .... That is the great thing about indexing.
2 Comments
Stephen23
on 23 Apr 2020
"I was just looking for a more efficeint way of doing this in order to do this."
Indexing is the more efficient way of doing this, certainly much more efficient than accessing numbered variables:
More Answers (0)
See Also
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!