Filter löschen
Filter löschen

Mtalab code for given equation gives answer different than simulink model

2 Ansichten (letzte 30 Tage)
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)

Antworten (0)

Kategorien

Mehr zu Get Started with MuPAD finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by