0% found this document useful (0 votes)
14 views8 pages

Matlab Assignment 23mic7015

Uploaded by

vijay.23mic7015
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)
14 views8 pages

Matlab Assignment 23mic7015

Uploaded by

vijay.23mic7015
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/ 8

MATLAB

ASSIGNMENT

MAT1008
SLOT: L47+48

NAME: K. VIJAY KUMAR

REG. NO. : 23MIC7015


1)Draw the four curves in one window:
(i) y1=1+x3 ; x ϵ [-10,10]
(ii) y2=5+x4 ; x ϵ [0,5]
(iii) y3= sinx ; x ϵ [-2𝜋,2𝜋]
(iv) y4= sinx + cosx ; x ϵ [-4𝜋,4𝜋]
Solution:
x1=-10:1:10;
y1=1+x1.^3;
subplot(2,2,1)
plot(x1,y1,'--')
title('First curve')

x2=0:1:5;
y2=5+x2.^4;
subplot(2,2,2)
plot(x2,y2,':')
title('Second curve')

x3=-2*pi:pi/100:2*pi;
y3=sin(x3);
subplot(2,2,3)
plot(x3,y3,'-.')
title('Third curve')

x4=-4*pi:pi/100:4*pi;
y4=sin(x4)+cos(x4);
subplot(2,2,4)
plot(x4,y4,'o')
title('Fourth curve')

Output:
2)Draw the surface of f = x3cosy + x2exp(y) ; x ϵ [-2,2] , y ϵ [-4,4].

Solution:
x=linspace(-2,2);
y=linspace(-4,4);
[x,y]=meshgrid(x,y);
f=x^3*cos(y)+x^2*exp(y);
surf(x,y,f)

Output:
3) Find the extreme values of the functions:
(i) f(x)= x3+x2-8x+5
Solution:
syms x real
y = x.^3+x.^2-8*x+5;
yx = diff(y,x)
c = solve(yx)
cmin = min(double(c));
cmax = max(double(c));
figure(1)
ezplot(y,[cmin-2,cmax+2])
hold on
yxx = diff(yx,x)
for i = 1:length(c)
T1 = subs(yxx, x,c(i));
T3= subs(y, x, c(i));
if (double(T1)==0)
sprinty('The test fails at x=%d',double (c(i)))
elseif (double(T1) < 0)
sprintf('The local maximum point x is %d', double(c(i)))
sprintf('The local maximum value of the function is %d', double (T3))
else
sprintf('The local minimum point x%d', double(c(i)))
sprintf('The local minimum value of the function is %d', double (T3))
% end
end
plot(double(c(i)), double(T3), 'r*');
end

Output:
(ii) f(x)= x/x2+1
Solution:
syms x real
y = x/((x^2)+2);
yx = diff(y,x)
c = solve(yx)
cmin = min(double(c));
cmax = max(double(c));
figure(1)
ezplot(y,[cmin-2,cmax+2])
hold on
yxx = diff(yx,x)
for i = 1:length(c)
T1 = subs(yxx, x,c(i));
T3= subs(y, x, c(i));
if (double(T1)==0)
sprinty('The test fails at x=%d',double (c(i)))
elseif (double(T1) < 0)
sprintf('The local maximum point x is %d', double(c(i)))
sprintf('The local maximum value of the function is %d', double (T3))
else
sprintf('The local minimum point x%d', double(c(i)))
sprintf('The local minimum value of the function is %d', double (T3))
% end
end
plot(double(c(i)), double(T3), 'r*');
end
Output:

You might also like