MATLAB for Beginners – Volume-1 – MATLAB Basics – Tutorials

Unit-3

Variables

  • We can assign values to variables. Matlab understands their data types automatically.
  • Comments start with % sign.

Examples

Type a = 1 to assign a value to a and press “Enter/Return” key. Now, MATLAB interprets it as an integer.

>> a=1 % integer  (Comments start with % sign)

a = 

      1

Another integer variable:

>> b=2 % integer

b = 
      2

Float Variable – Assign a decimal point to a variable (say, c) as shown below. Matlab interprets c as a float.

>> c=42.365 %float

Character Variable

>> d = ‘a’    % character

String Variable

>> s='school of engg‘  %string

Be the first to comment

Leave a Reply

Your email address will not be published.


*


twelve + one =