MATLAB: How to create a row/column vector of variable length composed of x1,x2,x3,…,xN

vector of letters

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!

Best Answer

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.