Activity-1: Introduction To Matlab Start Screen of MATLAB
Activity-1: Introduction To Matlab Start Screen of MATLAB
: AAVISHKAR
ROLL NO. : 211216
ACTIVITY-1
INTRODUCTION TO MATLAB
b) trace ():
c) rank ():
d) inv ():
e) c.*c :
To find:
p(3,5)
p(1,2)
p(3,1:5)
p([3,5],[3,5])
ACTIVITY-3(27-07-2022)
PLOT THE GRAPH
To plot the graph of a function, you need to take the follow-
ing steps −
• Define x, by specifying the range of values for the variable
x, for which the function is to be plotted
• Define the function, y = f(x)
• Call the plot command, as plot(x, y)
First we define the variables and assign the range for them:
• X1=[0:1:100]
• X2=[0:0.1:100]
• X3=linspace(0,2*pi,100)
• Y1=sin(x1)
• Y2=sin(x2)
• Y3=sin(x3)
• Y4=cos(x3)
• Y5=exp(x3)
For plotting the graphs we use the plot () and stem() key-
word:
• Plot(x3,y3)
• Plot(y3,y4)
• Plot(x3,y5)
• stem (x3,y3)
• plot(x3,y3,x3,y4)
• plot(x3,y3,’--’,x3,y4,’-*’)
• plot(x3,y3,’--r’,x3,y4,’-*b’)
• xlabel(‘X-value’)
• ylabel(‘y-value’)
• title(‘my-plot’)
• legend(‘sin(x)’,’cos(x)’)
Graphs:
• plot(x3,y3):
• plot(x3,y5):
• plot(y3,y4):
ACTIVITY-1
EXAMPLE = LET US PLOT THE GRAPH WHERE x = [0:5:100]; y = x; plot(x, y)
x = [0 : 0.01: 10];
y = sin(x);
g = cos(x);
plot(x, y, x, g, '.-'), legend('Sin(x)', 'Cos(x)')
SETTING COLOR IN
GRAPH: EXAMPLE
LET US DRAW THE GRAPH OF TWO POLYNOMIALS
4 3 2
· F(X) = 3X + 2X + 7X + 2X + 9 AND
3
· G(X) = 5X + 9X + 2
CREATE A SCRIPT FILE AND TYPE THE FOLLOWING CODE −