Printing - matrices, MATLAB Programming

Printing - matrices:

For matrices, the MATLAB unwinds the matrix column by column. For illustration, consider the random 2 × 3 matrix as shown below:

>> mat = randint(2,3,[1,10])

mat =

5  9  8

4  1  10

Identifying one conversion character and then the newline character will print the elements from the matrix in one column. The initial values printed are from the initial column, then the second column, and so forth.

>> fprintf('%d\n', mat)

5

4

9

1

8

10

If three of the %d conversion characters are specified, then the fprintf will print three numbers across on each line of output, but again the matrix is unwind column by column. It again prints first the two numbers from the initial column, and then the first value from the second column, and so forth.

>> fprintf('%d %d %d\n', mat)

5  4  9

1  8  10

If the transpose of the matrix is printed, though, using the three %d conversion characters, the matrix are printed as it appears whenever created.

>> fprintf('%d %d %d\n', mat') % Note the transpose

5  9  8

4  1  10

Posted Date: 10/18/2012 5:54:44 AM | Location : United States







Related Discussions:- Printing - matrices, Assignment Help, Ask Question on Printing - matrices, Get Answer, Expert's Help, Printing - matrices Discussions

Write discussion on Printing - matrices
Your posts are moderated
Related Questions
Problem 1.  Use Matlab to solve the following system of linear equations: 2x + y + 3z = 1 2x + 6y + 8z = 3 6x + 8y + 18z = 5 Capture Matlab code and the result in a text fi

Answers should be submitted in an MS Word document. Simulations should accompany answers in a separate MATLAB file. 1)  Queuing Simulator: Consider a communications router that

The cost of sending a package by an express delivery service is $15 for the first two pounds, and $4.25 for each pound over two pounds. Write a program that computes the cost of

How to Open Simpower: 1. Open MATLAB 2. In the "Command Window" write ' simulink ' and press Enter or click on the Simulink icon. 3. Simulink Library Browser w

please tell me the procedure of Anova two Way analysis in matlab?

Generate a script: To generate a script, click File, then New, and then M-file. The new window will appear known as the Editor. To generate a new script, simply type the serie


Generates sin or cos wave using plot functions: The script generates an x vector; iterating through all the values from 0 to 2*π in steps of 2*π /40 gives sufficient points to

drow midpoint circle for scan converting acircle in matlab

1. Given these sinusoids: x 1 (t) = 0.5cos(25t+20°),   x 2 (t)=0.85cos(25t+160°) and   x 3 (t)= 0.81cos(25t-145°) (a)  Subplot the phasors X 1 , X 2 and X 3 corresponding t