Mtalab code for given equation gives answer different than simulink model
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with MuPAD 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!