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 …


This content originally appeared on DEV Community and was authored by Aatmaj

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?

➕➖✖️➗


This content originally appeared on DEV Community and was authored by Aatmaj


Print Share Comment Cite Upload Translate Updates
APA

Aatmaj | Sciencx (2021-07-12T04:14:23+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 ,<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 ]. 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 . 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: ]
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/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.