MATLAB MONDAYS?- Crash Course part-3

Welcome all! ❤️‍? This Monday let us learn about row and column vectors in MATLAB.?

Row and Column Vectors in MATLAB
We can create row vector in matlab by this syntax-

x=[-2,-1,0,-1,-2]

Similarly we can make column vectors using …



Welcome all! ❤️‍? This Monday let us learn about row and column vectors in MATLAB.?

Row and Column Vectors in MATLAB
We can create row vector in matlab by this syntax-

x=[-2,-1,0,-1,-2]

Similarly we can make column vectors using ‘:’ instead of ‘,’

x=[-2;-1;0;-1;-2]

Here is the output-

>> x=[2;3;4;5];
>> x

x =

     2
     3
     4
     5

>> x=[2,3,4,5,];
>> x

x =

     2     3     4     5

Sometimes, however we may require to create row or column vectors with large number of equidistant points. Example, for plotting values from -2 to 2, we may require to plot at steps of small units like 0.01. In that case, MATLAB provides a feature to unable creation of “Uniformly Based Vectors”
We can create such vectors by inputting startvalue, spacing and end value –

x=startvalue: spacing: endvalue

Here is an example-

>> x=-1:0.17:+1

x =

   -1.0000   -0.8300   -0.6600   -0.4900   -0.3200   -0.1500    0.0200    0.1900    0.3600    0.5300    0.7000    0.8700

Note- Vector ends on the largest value within range. That is, after adding up consecutive spacing values, vector ends in the greatest value smaller than the endvalue

If the spacing value is not mentioned, it defaults to one-

>> y=[-4:5]

y =

    -4    -3    -2    -1     0     1     2     3     4     5

Similarly, all this can be done for column vectors as well

The transpose operator
The row vectors can be transformed into column vectors using the transpose operator

x=(Startvalue:spacing:endvalue)'

This operator transposes any matrix (flips over rows and columns)

>> z=(-3:1)

z =

    -3    -2    -1     0     1

>> x=(z)'

x =

    -3
    -2
    -1
     0
     1

That’s all for this week. For any suggestions or doubts, please comment below ? or gmail me. ?️ Follow me for updates…
LinkedIn
Gmail

Bye for now ?
Meet you all soon?

➕➖✖️➗


Print Share Comment Cite Upload Translate
APA
Aatmaj | Sciencx (2024-03-28T10:18:12+00:00) » MATLAB MONDAYS?- Crash Course part-3. Retrieved from https://www.scien.cx/2021/07/12/matlab-mondays%f0%9f%92%a5-crash-course-part-3/.
MLA
" » MATLAB MONDAYS?- Crash Course part-3." Aatmaj | Sciencx - Monday July 12, 2021, https://www.scien.cx/2021/07/12/matlab-mondays%f0%9f%92%a5-crash-course-part-3/
HARVARD
Aatmaj | Sciencx Monday July 12, 2021 » MATLAB MONDAYS?- Crash Course part-3., viewed 2024-03-28T10:18:12+00:00,<https://www.scien.cx/2021/07/12/matlab-mondays%f0%9f%92%a5-crash-course-part-3/>
VANCOUVER
Aatmaj | Sciencx - » MATLAB MONDAYS?- Crash Course part-3. [Internet]. [Accessed 2024-03-28T10:18:12+00:00]. Available from: https://www.scien.cx/2021/07/12/matlab-mondays%f0%9f%92%a5-crash-course-part-3/
CHICAGO
" » MATLAB MONDAYS?- Crash Course part-3." Aatmaj | Sciencx - Accessed 2024-03-28T10:18:12+00:00. https://www.scien.cx/2021/07/12/matlab-mondays%f0%9f%92%a5-crash-course-part-3/
IEEE
" » MATLAB MONDAYS?- Crash Course part-3." Aatmaj | Sciencx [Online]. Available: https://www.scien.cx/2021/07/12/matlab-mondays%f0%9f%92%a5-crash-course-part-3/. [Accessed: 2024-03-28T10:18:12+00:00]
rf:citation
» MATLAB MONDAYS?- Crash Course part-3 | Aatmaj | Sciencx | https://www.scien.cx/2021/07/12/matlab-mondays%f0%9f%92%a5-crash-course-part-3/ | 2024-03-28T10:18:12+00:00
https://github.com/addpipe/simple-recorderjs-demo