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
how to design a digital fir filter using anfis in matlab.get the code for that.

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

Documentation: It is very important that all the scripts be documented well, so that the people can understand what the script does and how it accomplishes that. One way of do

In this lab, we implement vectors, script and functions with plot. Plot function is used to plot the point into graph. These plots are handled by handle (h).  These handle is used

Define a function: The radius of a circle is passed to the function to input argument  rad; the function computes the area of this circle and stores it in the output argument

the basic equation of modeling radioactive decay is where the amount of the radioactive substance is at time and is the decay rate. Some radioactive substances decay into other rad

You will write functions • B=null basis(A,tol); • B=range basis(A,tol); The function null basis takes a matrix A as input, and outputs a basis for the null space of A, obtained via

Illustration of Modifying Elements: Illustration, the fifth element in the vector newvec is 9 >> newvec(5) ans = 9 The subset of a vector, that would be a vector it

1. Assume that there exists a surface that can be modeled with the equation:  z = e-(x 2 + y 2 ).  a) Calculate ∇z at the point (x = 0, y = 0). b) In addition, use MATLAB to

write matlab program for Cubic Spline Sweep Surface