Saturday, 29 August 2015

INTRO TO VARIABLES IN MATLAB

A Variable is a object that contains a specific value.A variable can be initialized using an "=" operator (assignment operater)
Command:
          a= 10        
       
          % for assigning a integer to a variable

 note: " % " is used to represent comment .The line starting with " % " symbol is skipped from execution output is shown below
  integer

Same syntax applies for decimals
command:
           b= 0.01
the output is


  decimal for

substituting the value in a function
command
c = sin(a)
the output is

  fn

This is how the variables are used in MATLAB

note: as you noticed we didn't put any semicolon after the command as it is popularly used in many programming languages,This is because if we use semicolon it will execute the command but the result is not displayed.

Screenshot (9)

clc command:

"clc " command is used to clear the screen.it is very important command as it is useful everytime

MATLAB INTRODUCTION

Matlab is a is a is a multi-paradigm numerical computing environment and fourth-generation programming language. MATLAB stands for MATRIX LABORATARY. The MATLAB software looks like
  view

We Have write code on m-File. To create m-File click on new script.
  new script

 m-File looks like the image below.Code should be written in the workspace given below in the image
  newscriptfile

after writing the code to execute it click on the run as shown below run

the m-file commands are gonna executed and shows the results on the command window in line to line execution format. we can also directly enter the code in command window without m-file.
  new script
The commands you enter are saved in command history.you can retrieve them at any time.


  commandhistory if

command window isnt present enter "commandhistory" on command window (without " ")

 You can also search for documentation on search box. search

suggestion: enter the code in command window that helps to see what happens for each and every line of code we enters.Disadvantage of using directly in command window is that we cannot save the results.