I want print the matrix, in orginal matrix from but it displays it as a series of coloumns.
Mostrar comentarios más antiguos
H_Mat=[1, 0, 1, 0, 1, 0, 1, 0;
1, 0, 0, 1, 0, 1, 0, 1;
0, 1, 1, 0, 0, 1, 1, 0;
0, 1, 0, 1, 1, 0, 0, 1];
[row,coloumn]=size(H_Mat);
for i = 1:row
for j = 1:coloumn
fprintf (' %d,', H_Mat (i,j));
Respuesta aceptada
Más respuestas (2)
Shashank Prasanna
el 31 de En. de 2013
Try:
H_Mat=[1, 0, 1, 0, 1, 0, 1, 0; 1, 0, 0, 1, 0, 1, 0, 1; 0, 1, 1, 0, 0, 1, 1, 0; 0, 1, 0, 1, 1, 0, 0, 1];
dlmwrite('test1.txt', H_Mat,'delimiter',' ')
1 comentario
Krishna Prasad Rao
el 31 de En. de 2013
Editada: Krishna Prasad Rao
el 31 de En. de 2013
Image Analyst
el 31 de En. de 2013
Perhaps you just need to swap the order of rows and columns in the for loops, and add a new line:
for j = 1:row
for i = 1:coloumn
fprintf (' %d,', H_Mat (j,i));
end
fprintf ('\n');
end
In the command window:
1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 0, 1, 0, 1, 0, 1,
0, 1, 1, 0, 0, 1, 1, 0,
0, 1, 0, 1, 1, 0, 0, 1,
7 comentarios
Krishna Prasad Rao
el 31 de En. de 2013
Editada: Krishna Prasad Rao
el 31 de En. de 2013
Image Analyst
el 31 de En. de 2013
I don't know how you can do that. I mean, like putting the gigantic brackets going up and down the entire left and right side. Perhaps with Latex or something, but I don't know. Maybe you can use ActiveX to create something like that in Microsoft Word's equation editor. Where do you need this pretty-looking depiction of the matrix? Is it OK to be in a Word document? Because I'm not sure you can have that in the command window, where I've seen only normal ASCII text.
Krishna Prasad Rao
el 1 de Feb. de 2013
Shashank Prasanna
el 1 de Feb. de 2013
Krishna, MATLAB command like is not exactly for pretty printing, atleast not at this moment. You can try mupad if you have the symbolic toolbox which does do better. Other than that you are out of luck in the MATLAB environment.
Krishna Prasad Rao
el 1 de Feb. de 2013
Editada: Krishna Prasad Rao
el 1 de Feb. de 2013
Image Analyst
el 1 de Feb. de 2013
Editada: Image Analyst
el 1 de Feb. de 2013
The colon, when used where you'd normally use an index, means "all". So in your case, where the colon is in the first index, which corresponds to the "rows" index, the colon mean "all rows". So X(:,p) means "all rows in column #p." Basically it extracts out the pth column from the matrix into a vertical column vector.
Krishna Prasad Rao
el 5 de Feb. de 2013
Categorías
Más información sobre Operators and Elementary Operations 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!