Posts

Showing posts with the label Maths

MATLAB Week- 6

Image
MATLAB Partial Derivatives Week: 6 clear all clc syms x y z= input( 'enter the function' ) x1= input( 'enter the x value' ) y1=input( 'enter the value of y' ) z1 = subs(subs(z,x,x1),y,y1) ezsurf(z,[x1-2,x1+2]) f1=diff(z,x) slope x =subs(subs(f1,x,x1),y,y1) [x2,z2]=meshgrid(x1-2:25:x1+2 ,0:0.5:10) y2=y1*ones(size(x2)) hold on surf(x2,y2,z2) t=linspace(-1,1) x3=x1+t y3=y1*ones(size(t)) z3=z1+ slopex*t; line(x3,y3,z3, 'color' , 'blue' , 'line width' ,2) Question 1) f(x)= x^2 - 2*y^2                                      Question 2) f(x)=x^3+y^3+6*x*y-1 at (1,1) Question 3) f(x)= 4-x^2-2*y^2 at (1,1)

MATLAB Week-5

MATLAB Laplace transforms and limits Week: 5 LAPLACE TRANSFORM clc clear all syms t s f=input( 'Enter the function in terms of  t:' ); F=laplace(f) LAPLACE TRANSFORM OF UNIT STEP FUNCTION clear all clc syms x g1=x*(heaviside(x-0)-heaviside(x-1)); g2=(2-x)*(heaviside(x-1)-heaviside(x-2)); f=g1+g2; F=laplace(f) xv=linspace(0,2,100);    g1v=subs(g1,x,xv); g2v=subs(g2,x,xv); fv=subs(f,x,xv); subplot(3,1,1) plot(xv,g1v, 'r.' ) subplot(3,1,2) plot(xv,g2v, 'r.' ) subplot(3,1,3) plot(xv,fv, 'r.' ) LAPLACE TRANSFORM OF PERIODIC FUNCTION clc clear all syms ts T=input( 'enter the period of the periodic function : ' ); n=input( 'enter the number of partitions in one full period : ' ) fun = 0*t; for i=1:n a(i)=input( 'enter the left end point of the ith sub interval  :  ' ); b(i)=input( 'enter the right end point of the i...

MATLAB Week-4

Image
MATLAB Week: 4 clc clear all syms x y y1=input( 'Enter the Y1 Region value' ) y2=input( 'Enter the Y2 Regon value' ) ez1=ezplot(char(y1)) hold on ez2=ezplot(char(y2)) hold on t=solve(y1-y2) kokler=double(t) x1=linspace(kokler(1), kokler(2)) yy1=subs(y1,x,x1) yy2=subs(y2,x,x1) x1=[x1,x1] yy=[yy1,yy2] fill (x1,yy, 'g' ) f=int(y1-y2,t(1),t(2)) Question 1) y=x^2-2*x, y=x               Maxima and Minima clc clear all syms x real f=input( 'Enter the function f(x):' ) fx=diff(f,x) c=solve(fx) cmin=min(double(c)) cmax=max(double(c)) ezplot(f,[cmin-2,cmax+2]) hold on fxx=diff(fx,x) for i = 1:1:size(c)     T1=subs(fxx,x,c(i))     T3=subs(f,x,c(i)) if (double(T1)==0)     sprintf( 'The point x is inflexion point %d' , double (c(i))) else     if (double(T1)<0)       ...

MATLAB Week-3

Image
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) ...

MATLAB WEEK-2

Image
MATLAB Plotting of curves and surfaces Week: 2 METHOD 1 x=linspace(0,1,101) plot(x,x.^3, 'r+' ,x,sin(x), 'b-' ,x,exp(x), 'g.' ) METHOD 2 using Hold on clear all x=linspace(0,1,101) plot(x,x^3, 'r*' ) hold on plot(x,sin(x), 'g.' ) hold on plot (x,exp(x), 'b+' ) If we remove hold on, only last graph will be displayed. METHOD 3 using subplot x=0:.1:2*pi; subplot(2,2,1); plot (x,sin(x)); subplot(2,2,2); plot(x,cos(x)); subplot(2,2,3); plot(x,exp(-x)); subplot(2,2,4); plot(x,sin(3*x)); Diffrentiation syms x y f=x^2+2*x*y+y*sin(x) diff(f,x) diff(f,y) f =2*x*y + y*sin(x) + x^2 ans = 2*x + 2*y + y*cos(x) ans = 2*x + sin(x) Integration syms x f=x^3 + 3*x^2 + 5*x + 12 int(f,x,0,2) f = x^3 + 3*x^2 + 5*x + 12 ans = 46 Plotting graph syms x f=sin(2*x)+ cos(3*x) ezplot(f) ...