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

Need help programming in Matlab for airy equations

Write a MATLAB program that calculates the arithmetic mean, and the root-mean-square average for a given set of values. The output should be formatted as follows: Y

For the 66kV subtransmission network shown below, calculate the following, using a MATLAB Simulink Power System Blockset model: 1. Three phase, phase-to-phase and phase-to-earth

Write a function called threshold2 (in a file called 'threshold2.m'). The function takes an arbitrary number of input variables. The first input variable, t, is required and is the

1) Convert the table into format convenient for the processing with MATLAB. 2) Prepare a program that perform K Nearest Neighbours algorithm using Euclidian distance. (Your prog

Format command: The format command can be used to control the spacing between the MATLAB command or expression and the outcome; it can be either compact or loose. >> format

I need my data mining assignment done. Can you guys help me with that?

Call to length function: The call to length function consists of the name of the function, followed by an argument in the parentheses. This function takes the argument, and re

Order of precedence: As with the numerical operators, it is significant to know that the operator precedence rules. Table below shows the rules for the operators which  have b