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
Writing data to a File: The save function can be used to write a data from the matrix to the data file, or to append a data file. The format is as shown below: save filenam

Write a matlab function that calls eig and generates an estimate of the smallest three eigenvalues and associated eigenfunctions of the negative Laplacian operator on ?. (Hint: thi

a. Run the simulation you developed for 10 one-day periods. Provide a table of the Peak Power required for each day. b. Based on this information, and the fact additional capaci

A band pass FIR filter is required to pass frequencies from 5KHz to 8KHz, using a sample rate of 40K i) Explain how this would map to normalization sampling frequencies in radia

Illustration of script Documentation: For illustration, the script to compute the area of a circle could be modified to have comments: The first comment at the startin

how do you make a program for a parachute man falling to determine his terminal velocity, having in consideration the drag force (cv^2). I have the formula to be v(i+1)=v(i)*delta(

Produce a random real number: To produce a random real number in the range from low to high, at first create the variables low and high. And then, use the expression rand*(hig

Calculate the gray level value for all the pixels, Computer Graphics An 8x8 image f[i,j] has gray levels given by the following equation: f [i , j]= ? i-j ? ; i,j=0,1,2,3,4,5,6,7.

Illustration of Output statements: For illustration, >> disp('Hello') Hello >> disp(4^3)   64 The formatted output can be printed to the screen by using the fpr

You are a quant analyst reporting directly to a portfolio manager. Your manager requires you to generate a simple code to compute several statistics for the following potential por