How to display a column vector row by row
Mostrar comentarios más antiguos
Hi all,
I have a program that will solve a linear system with any amount of rows and columns. I am displaying the solution to the sytem, which is answered in a row vector form.
Currently my answer is formatted as, disp(X):
1
1
When I would like the program to format it as
x1 = 1
x2 = 1
I am not sure how to display the specific row answer.
Thanks for the help!
2 comentarios
Image Analyst
el 30 de Nov. de 2018
Is X a row vector or a 2-D Matrix? What is x1 and x2? Are those X(1,:) and X(:, 2) - the rows of matrix X? Why do you get 1 and 1 the first time and 1 and 2 the second time?
Jacob Varnell
el 30 de Nov. de 2018
Respuesta aceptada
Más respuestas (1)
TADA
el 30 de Nov. de 2018
arrayfun(@(x, i) disp(['x' num2str(i) ' = ' num2str(x)]),x,(1:numel(x))')
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!