O'Reilly logo

MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] by Manoj Kumar Sharma, Ashok Kumar Goel, Raj Kumar Bansal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.2. Scalars and Vectors

A scalar is a (1 × 1) matrix containing a single element only. A column vector is a (m × 1) matrix that has m number of rows but a single column only. A row vector is a (1 × n) matrix which has n number of columns and has only one row.

3.2.1. Assigning Data to Elements of a Vector/Scalar

All the elements of a row vector are separated by blank spaces or commas and are enclosed in square brackets.

For example, a row vector q = [1 2 4] can be entered at the Command Window as follows:

 q = [1 2 4];
orq = [1,2,4]

All the elements of a column vector are separated by semicolons and are enclosed in square brackets. For example, a column vector q is entered, as follows:

q = [1; 2; 4];

Variable q is a column vector and has one ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required