Assigning names to values in vector

조회 수: 6 (최근 30일)
Sebastian Daneli
Sebastian Daneli 2019년 11월 3일
댓글: Sebastian Daneli 2019년 11월 4일
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
Steven Lord
Steven Lord 2019년 11월 4일
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
Sebastian Daneli 2019년 11월 4일
Basically I am switching bases in a matrix (simplex method), so I need to keep track on the vectors. In the end I must also update the values that I resive

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 11월 3일
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
Walter Roberson
Walter Roberson 2019년 11월 4일
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
Sebastian Daneli 2019년 11월 4일
Tried to make sense of what you linked me, but I'm a total noob and can't figure out a solution

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by