Assigning names to values in vector
Ältere Kommentare anzeigen
I would like to keep track on my vectors and need to assign a name to each entry.
For example: xN=[2 1]=[x1 x2], or something like it.
Is it possible to assign the values a handle of some sort? I'm switch the values around, and I don't know beforehand were the going to end up.
So the name should not interfere with the algebraic operations
2 Kommentare
Steven Lord
am 4 Nov. 2019
I assume this is only one step in a larger project. If you describe that larger project (why are you "switch [sic] the values around"?) we may be able to offer an alternative way to solve the problem, either by doing this tracking or avoiding the need to track.
Sebastian Daneli
am 4 Nov. 2019
Antworten (1)
Walter Roberson
am 3 Nov. 2019
No, it is not possible to assign a handle to a value. Use symbolic variable names and subs() as needed. For example,
x = sym('x', [1 5]);
y = sum(x.^(0:4));
xvals = randi([-9 9], 1, 4);
subs(y, x, xvals)
xvals2 = xvals(randperm(length(xvals)));
subs(y, x, xvals2)
3 Kommentare
Sebastian Daneli
am 3 Nov. 2019
Bearbeitet: Sebastian Daneli
am 3 Nov. 2019
Walter Roberson
am 4 Nov. 2019
Of course there are ways. I already linked you to an explanation of why most of those ways are not good mechanisms to use.
Sebastian Daneli
am 4 Nov. 2019
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!