EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • All Courses
    • All Specializations
  • Blog
  • Enterprise
  • Free Courses
  • All Courses
  • All Specializations
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Column Vector Matlab
 

Column Vector Matlab

Priya Pedamkar
Article byPriya Pedamkar

Column Vector Matlab

Introduction to Column Vector Matlab

MATLAB is a simple programming language owned and developed by MathWorks. It was started as a programming language for matrices as programming of linear algebra was simple. Matlab can be implemented as batch jobs and also as interactive sessions. In this article, we will understand a very basic and useful element of MATLAB called ‘Column Vector Matlab’.

 

 

Uses of Column Vector Matlab:

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

  • Computation
  • Simulation
  • Modeling
  • Data analytics
  • Prototyping
  • Application development
  • Engineering & Scientific graphics

Column vectors in MATLAB are created by keeping the required set of elements in a square bracket. A semicolon is then used for delimiting the elements. In simpler words, we can create a column vector using a square bracket [ ]. Elements in a column vector are then separated by either a newline or a semicolon (newline can be obtained by pressing the Enter key).

Examples of Column Vector Matlab

Now let us understand this by a couple of examples:

Example #1 – Creating a Column Vector with 3 Elements

Code:

a = [1; 3; 5]

The output that we will get will be a single column with elements 1, 3, 5.

Output:

3 Elements

Example #2 – Creating a Column Vector with 5 Elements

Code:

a = [1; 3; 5; 7; 9]

The output that we will get will be a single column with elements 1, 3, 5, 7, 9

Output:

Column Vector Matlab 1-2

The elements in a column vector may also be the result of arithmetic operations. Let us understand this by the following examples:

Example #3 – Creating a Column Vector with Different Elements

Let us try to create ‘y’, a column vector with elements having the following description:

  • 20 inches converted to cm (1 inch is 2.54 cm).
  • 140 degrees Fahrenheit converted to Centigrade (conversion formula is Centigrade = 5 (F – 32) / 9).
  • 120 lbs in kgs (one kg = 2.2 lbs).

Code:

y = [20 / 2.54; (5 / 9) * (140 - 32); 120 / 2.2]

The output that we will get will be a single column with 3 elements.

Output:

conversion formula

Example #4 – Creating a Column Vector with Arithmetic Operations

Let’s take a simpler example which involves simple arithmetic operations:

Code:

y = [20 + 2; 59 - 9; 120 / 2]

The output that we will get will be a single column with 3 elements.

Output:

 arithmetic operations

Operations Between Row and Column Vector in Matlab

One thing to remember here is that we access elements of a column vector using normal round brackets ( ) which is exactly how we access elements of row vectors. Vector arithmetic is also the same for column vectors and for row vectors. The restriction to be kept in mind is that we cannot mix column and row vectors.

Convert Vectors using Transpose: We can convert our column vector into a row vector by using TRANSPOSE. Creating a row vector from a column vector using Transpose.

Code:

a = [1; 3; 5]’

Output:

Column Vector Matlab 1-5

The output that we will get will be a single row with elements 1, 3, 5. As we can observe, instead of getting a column vector here, we have received a row vector. This is because we have used a ‘Transpose’ in the MATLAB command.

Conclusion

  • Square brackets can be used to create not only column vectors but also row vectors.
  • Square brackets in MATLAB, with elements separated by semicolons, are used for creating column vectors.
  • Transpose ‘ converts a column vector into a row vector and vice versa.
  • If we define a row vector x = [1 2 3 4] with elements 1, 2, 3, 4, it is completely different from the column vector y = [1; 2; 3; 4] with elements 1, 2, 3, 4. Notice here the difference of a semicolon between the elements.

Recommended Articles

This is a guide to Column Vector Matlab. Here we discuss the basic concept and uses of column vector Matlab along with the examples and code implementation. You may also look at the following articles to learn more –

  1. Methods to use Comet() in Matlab
  2. Examples of Log Plot Matlab
  3. Types of 3D Plots in Matlab
  4. What is Repmat in Matlab?
Primary Sidebar
Footer
Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW