How to create a row/column vector of variable length composed of x1,x2,x3,...,xN
13 views (last 30 days)
Show older comments
Timothy Corley
on 25 Nov 2017
Commented: Timothy Corley
on 27 Nov 2017
I have a column vector, x, of solutions for the equation ax=b, length of x = N, and I want to label which solution is which. N varies depending on the size of the matrix inputted into the function. Want a new vector in the form of xsol = [labels,x] because when you get around 1000 solutions it's not so easy to see what the solutions correspond to. Any help would be greatly appreciated!
3 Comments
Accepted Answer
Birdman
on 25 Nov 2017
Edited: Birdman
on 25 Nov 2017
You may create x vector symbolically by writing
x=sym('x',[N 1]);
Then, solve the equation by writing
x=inv(a)*b;
Hope this helps.
More Answers (1)
Image Analyst
on 26 Nov 2017
What is x1, x2, etc.? Do you mean x(1), x(2), etc.????? Otherwise you need to define x1 x2, etc. If it's x(1), x(2), etc. then
labels = x
and xsol is
xsol = [labels, x];
Not sure what good they are, but that's what you asked for.
0 Comments
See Also
Categories
Find more on Entering Commands 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!