Mtalab code for given equation gives answer different than simulink model
2 views (last 30 days)
Show older comments
how can I solve this equation by ode45 matlab code? Here z and zdot vary with time (t = 0:0.02:3) and simulation is also made for 3 seconds. My code gives answer different than that of Simulink model prepared for the same equation.Unable to figure out the reason or my matlab code is wrong? Equation is :
dydt = (-lambda)*(abs(zdot))*(Y)*(abs(Y)^(n-1))-(beta)*(z)*(abs(Y)^n) + ((A)*(zdot));
where,z = 2*t^2 , zdot= diff(z)
Function File: (Working) function dYdT = boucwen(t,Y) lambda = 1; beta = 0; A = 1.5; n = 2; syms t z = 2*t^2; zdot = diff (z); dydt = (-lambda)*(abs(zdot))*(Y)*(abs(Y)^(n-1))-(beta)*(z)*(abs(Y)^n) + ((A)*(zdot)); for t = 0:0.02:3 Z = z; Z = subs(z,t) Zdot = zdot; Zdot = subs(zdot,t) dYdT=dydt; dYdT=subs(dydt,t); end
m-script file for solution
timeperiod = [0:0.02:3] ; initialvalue = [0]; [t,Y] = ode45(@boucwen,timeperiod,initialvalue); plot(t,Y)
0 Comments
Answers (0)
See Also
Categories
Find more on Get Started with MuPAD in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!