Introduction To Variable and Plot in MATLAB.
Introduction To Variable and Plot in MATLAB.
Objective:
i. To familiarize with MATLAB and some basic commands of MATLAB.
ii. To know about variable and variable types in MATLAB.
iii. To know about Matrix manipulation in MATLAB.
iv. To learn about plotting 2D graphs in MATLAB.
Description of Instructions/Functions:
clc- Clear Command Window. In the command window whenever clc
command applied the whole window will clear.
rand- Uniformly distributed random numbers. For a fixed range rand
command can take random number from the range.
linspace- Generate linearly spaced vector. For a fixed range linspace
command can take fixed number from the range.
sum- Sum of time series data. Add all data in the mentioned variable.
.*- Multiplication. Multiply variables data.
*- Matrix multiplication. Multiply matrix variable data.
save- Save workspace variables to file.
disp- Display value of variable.
whos- List variables in workspace.
clear- Remove items from workspace, freeing up system memory.
sqrt- Square root. With this command a variable can be square root.
plot- 2-D line plot. Using this command a 2D plot can be created.
scatter- Scatter plot. Using this command a scatter plot can be created.
title- Add title. Using this command a title can be add on the top of the plot
sgtitle- Add title to subplot grid. Using this command a title can be add on
the top of the all subplot
xlabel- Label x-axis. Using this command label can be add on x axis.
ylabel- Label y-axis. Using this command label can be add on y axis.
hold- Retain current plot when adding new plots.
subplot- Create axes in tiled positions. Multiple plot can be create using this
command.
Program, Result & Analysis:
In this program we have considered two variables ET_45 and EEE _45.
Using the ‘size’ command we can find the type of data of this variables. Here the
first variable data type is 1×1 . The second variable data type is 2×3.
3. Using Format Command:
In this program we used three variables where in the first variable colon
is used as a Unit space vector which start from 0 and end at 10. In the second
variable colon is used as specified increment which start from 0 and increment
2 by 2 to 10. In the third variable the increment is 0.5 by 0.5 from 0 to 2.
7. Using colon two subscript:
In this program there are two matrix A & B. At first we use horizontally
joining operation to join A & B matrix. Again we used vertically joining
operation to join A & B matrix. We can see that the output of the operation is
accurate as we wanted using MATLAB.
In this program we use plot command to draw plot of the two matrix A
and B. In the plot three lines are indicating 1st , 2nd and 3rd column respectively
of combination of A and B.
13. Creating wave using plot:
Discussion:
In this experiment we have learned about basic commands of MATLAB.
We practice different program using these commands. We have learned about
different variables type in MATLAB software. We have familiarized with
matrix and it’s different type of operation in MATLAB. We have also known
about 2D graphs and it’s different type of model.
_________________