MATLAB Week-3
MATLAB
Application of derivatives
Week: 3
syms x
% Declaring a symbolic
variable
y =input('Enter the
function f in terms of x:');
x1 =input('Enter x value
at which tangent:');
ezplot(y,[x1-2,x1+2])
% Easy plotting
hold on
y_derivative= diff(y,x); %Diffrentiation
in MATLAB
slope= subs(y_derivative, x,x1);
% Finding slope on that
point
y1=subs(y,x,x1); % Finding
the value of function at the given point
plot(x1,y1,'r:*')
tgt_line = slope*(x-x1)+y1 ; %Tangent
line equation at the given point
h=ezplot(tgt_line, [x1-2,x1+2]); %Plotting
the tangent line
set (h, 'color','r')
hold off
Question 1) y=4-x^2, (-1,3)
Question 2) y=2*x^0.5, (1,2)

Question 3) y=x**3, (-2,-8)

Comments
Post a Comment