Skip to Main Content
UC Logo
Libraries | Ask the Libraries

MATLAB Resources

Introduction to MATLAB and MATLAB Scripting

Variables

Variables

  • A variable should have a name
  • Values should be assigned to the variable with a '=' operator
  • A variable can have an alphabetical character value  K = 'l'
  • Variable can also have an integer value K = '2009'
  • Decimal values can also be assigned to a variable

           Pi = '3.14159'

  • The vector is a collection of numbers in one dimension
    • t = [12 15 18 33], if individual elements are separated by spaces, then they are stored as individual columns in MATLAB
    • t = [24;3;56;92], if individual elements are separated by semicolon, then they are stored as individual rows in MALTAB

             Note :- If vectors or matrices change size in your calculations then their size should be preallocated. 

University of Cincinnati Libraries

PO Box 210033 Cincinnati, Ohio 45221-0033

Phone: 513-556-1424

Contact Us | Staff Directory

University of Cincinnati

Alerts | Clery and HEOA Notice | Notice of Non-Discrimination | eAccessibility Concern | Privacy Statement | Copyright Information

© 2021 University of Cincinnati