matlab exerxise 2.pdf - EXPERIMENT-2 Name:M.Deepshika...

This preview shows page 1 - 4 out of 10 pages.

EXPERIMENT-2 Name: M.Deepshika Registration no.: 18MIS0241 Faculty Name: Selva Kumar EXERCISE-2A: 1.Using MATLAB find the tangent to the curves y= √x at x=4 and show graphically. Program: clear all clc syms x y f = input( 'Enter the given function in variable x: ' ); x0 = input( 'Enter the x-coordinate of the point: ' ); y0 = subs(f,x,x0); fx = diff(f,x); m = subs(fx,x,x0); tangent = y0 + m*(x-x0); t_line=y-tangent; plotrange = [x0-3,x0+3]; ezplot(f,plotrange); hold on ; ezplot(tangent,plotrange) title( 'Tangent line plot' ) t=sprintf( 'The tangent to the given curve y= %s ... at the point (%d,%d) is y= %s' ,f,x0,y0,tangent); disp(t) Input: Enter the given function in variable x: x^(1/2) Enter the x-coordinate of the point: 4 Output: The tangent to the given curve y= x^(1/2) ... at the point (4,2) is y= x/4 + 1
Graph: 2. Using MATLAB find the tangent to the curves y=-sin(x/2) at the origin and show graphically. ;
Graph:

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture