Printing vectors and matrices, MATLAB Programming

Printing Vectors and Matrices:

For vector, if the conversion character and newline character are in the format string, it will print in a column in spite of of whether the vector itself is a row vector or a column vector.

>> vec = 2:5;

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

2

3

4

5

Note that this is a row vector. The column vector would print exactly in a similar way, as the column. Without the newline character, it would print in a row but the later prompt would appear on similar line:

>> fprintf('%d', vec)

2345>>

1225_Printing Vectors and Matrices.png

Though, in a script, a separate newline character could be printed to avoid such problem.

>> printvec

2345

>> 

If the number of elements in the vector is acknowledged, which many conversion characters can be specified and then the newline:

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

2 3 4 5

This is not very common, though, and is therefore not preferable.

Posted Date: 10/18/2012 5:52:58 AM | Location : United States







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

Write discussion on Printing vectors and matrices
Your posts are moderated
Related Questions
Complete assignment as per attached word doc. Include function files along with Matlab assignment file.

Example: Load from File and Plot Data: As illustration, a file known as timetemp.dat stores two lines of data. The first line is the time of the day, and the next line is the

Some recent column source designs incorporate ‘beam steering', where the phase of each element in the column is varied in order to change the angle at which the major lobe appears.

Illustrations of calling the rand function: The function ‘rand’ can be used to produce random real numbers; calling it produces one random real number in the range from 0 to

what is matlab

(a) Using Matlab, find and plot the magnitude of the DTFT of 10 samples of x(n) for n=[0:1:9] of x(n) = cos(2*pi*f1*n) + cos(2*pi*f2*n)  for f1=0.22 and f2=0.24 and pad zeros to ge


Using numerical techniques, plot the intensity distribution for LP 01 and LP 11 modes. Vary the value of V (reduce it to 1.5) and plot several of the intensity plots (of LP 01 )