I want print the matrix, in orginal matrix from but it displays it as a series of coloumns.
Ältere Kommentare anzeigen
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));
Akzeptierte Antwort
Weitere Antworten (2)
Shashank Prasanna
am 31 Jan. 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 Kommentar
Krishna Prasad Rao
am 31 Jan. 2013
Bearbeitet: Krishna Prasad Rao
am 31 Jan. 2013
Image Analyst
am 31 Jan. 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 Kommentare
Krishna Prasad Rao
am 31 Jan. 2013
Bearbeitet: Krishna Prasad Rao
am 31 Jan. 2013
Image Analyst
am 31 Jan. 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
am 1 Feb. 2013
Shashank Prasanna
am 1 Feb. 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
am 1 Feb. 2013
Bearbeitet: Krishna Prasad Rao
am 1 Feb. 2013
Image Analyst
am 1 Feb. 2013
Bearbeitet: Image Analyst
am 1 Feb. 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
am 5 Feb. 2013
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!