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)





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)


1225_Printing Vectors and Matrices.png

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

>> printvec



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
Compare results/performance with tridiagonal Gaussian elimination solver for the problem arising from -y''=f   on (0,1) with y(0)=0=y(1). You may also need to use sparse storage an

plase help me to convert a theory part of ammonia-vapour simple absorption system into matlab programmong

Example of Variables and assignment statements: The expression is computed and then that value is stored in the variable. For illustration, this is the way it would appear in

Scripts with Input and output: Placing all this together, we can implement the algorithm from the starting of this section. The following script computes and prints the area o

#defining matrix using only special commands

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

i need someone to write a matlab code to solve a model.

Write a script to determine the volume of a pyramid, which is 1/3 * base * height, where the base is length * width. On time the user to enter values for the length, width, and th

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

Operator Precedence Rules: A few operators have precedence over the others. For illustration, in the expression 4 + 5 * 3, the multiplication takes the precedence over additio