Pathhacker

0 118 0
MATLAB code to solve the differential equational

MATLAB code to solve the differential equation is

clc
clear all
syms x k1 k2
a=input('enter the coefficient of D2y:');
b=input('enter the coefficient of Dy:');
c=input('enter the coefficient of y:');
a1=a/a;b1=b/a;c1=c/a;
eq='a1*x^2+b1*x+c1=0';
eq1=subs(eq,'[a1,b1,c1]',[a1,b1,c1]);
r=solve(eq1,'x')
if imag(r)~=0
    y1=exp(real(r(1))*x)*cos(imag(r(1))*x)
    y2=exp(real(r(1))*x)*sin(abs(imag(r(1)))*x)
elseif r(1)==r(2)
    y1=exp(r(1)*x);
    y2=x*exp(r(1)*x);
else
    y1=exp(r(1)*x);
    y2=exp(r(2)*x);
end
W=simplify(y1*diff(y2)-y2*diff(y1));
if W~=0
    y_h=k1*y1+k2*y2;
end
R=input('enter the nonhomogeous part:');
y_p=-y1*int(y2*R/W)+y2*int(y1*R/W)
y=simplify(y_h+y_p)
i_1=input('enter the initial condts as row vector[x y]:');
i_2=input('enter initial condts as row vector[x Dy]:');
y1=subs(y,x,i_1(1))
y2=subs(diff(y),x,i_2(1))
eqn1=y1-i_1(2)
eqn2=y2-i_2(2)
[k1 k2]=solve(eqn1,eqn2)
disp('Required complete soloution is:')
C_S=subs(y) 
ezplot(C_S,[0 3])

Tags

MATLAB code to solve second order differential equations using laplace transform MATLAB code to solve and visualize solutions of the second…
Profile photo of Madhu by Madhu
0 108 0
MATLAB code to visualize 2D vector field MATLAB code to visualize 2D vector field Syms x y…
Profile photo of Madhu by Madhu
0 114 0
Matlab code for Generation of unit ramp sequence %------------Generation of unit ramp sequence------------- a=input('Enter desired length of the…
Profile photo of Madhu by Madhu
0 108 0
Your nameYour emailYour text

Leave a Reply

Log in
Register
Send message