0% found this document useful (0 votes)
25 views6 pages

Lab Assignment - 1: Name: Savio K Santhosh Reg No: 21BRS1273

This document contains the details of 4 MATLAB assignments - plotting functions, plotting another function using ezplot, finding the derivative of a function at a point, and integrating a function between limits. For each assignment, the aim, MATLAB code, command window output and result is provided.

Uploaded by

Savio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views6 pages

Lab Assignment - 1: Name: Savio K Santhosh Reg No: 21BRS1273

This document contains the details of 4 MATLAB assignments - plotting functions, plotting another function using ezplot, finding the derivative of a function at a point, and integrating a function between limits. For each assignment, the aim, MATLAB code, command window output and result is provided.

Uploaded by

Savio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Name: Savio K Santhosh

Reg No: 21BRS1273

Lab Assignment –1

1.
Aim: To plot the functions f(x) = x + sin x and g(x)= x+ cos x for x ∈ [0, 2π], in the same figure.
Label your x and y axes and add a title to your plot and also add different colours, line styles
and markers.

MATLAB Code:
clc
clear all
x=linspace(0,2*pi,25);

y1=x+sin(x);
plot(x,y1,'g:*')
xlabel('x-axis')
ylabel('y-axis')

title('f(x)+g(x)')
hold on
y2=x+cos(x);
plot(x,y2,'b--o')
hold off

Command Window Output:


Graph:

Result:
Program successfully executed.
2.
Aim: Plot the function x2 + 8x + 72 in the interval [-10 10] using ezplot and Label your x and y
axes and add a title to your plot.

MATLAB Code:
clc
clear all
ezplot('x^2+8*x+72',[-10 10])
xlabel('x-axis')
ylabel('y-axis')

title('x^2 + 8x + 72')

Command Window Output:

Graph:
Result:
Program successfully executed.

3.
Aim: Find the derivative of the curve y = x3 - 3x2 + 10 at x = 3.

MATLAB Code:
clc

clear all
syms x real
y=x^3-3*x^2+10;
fx=diff(y);
c=eval(subs(fx,x,3));
fprintf('Derivative of function is: ')
disp(fx)

fprintf('Derivative of function at x=3 is: ')


disp(c)

Command Window Output:

Result:
Program successfully executed.

4.
Aim: Integrate the function x3 + 8x2 - 4x + 42 with lower limit 1 and upper limit 5.

MATLAB Code:
clc

clear all
syms x real
y=x^3+8*x^2-4*x+42;
f1=int(y,x);

c=eval(subs(f1,x,1));
d=eval(subs(f1,x,5));
fprintf("Integral of function is:")
disp(f1)
fprintf("Integral of function with limits 1-5 is:")

disp(d-c)

Command Window Output:

Result:
Program successfully executed.

You might also like