フィルターのクリア

Mtalab code for given equation gives answer different than simulink model

1 回表示 (過去 30 日間)
Pankaj Sharma
Pankaj Sharma 2018 年 6 月 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 件)

カテゴリ

Help Center および File ExchangeGet Started with MuPAD についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by