Plotting solutions of differential equations in Simulink

33 次查看(过去 30 天)
The following Simulink model solves the differential equation t - 4x(t) = x''(t), and generates the plot below for x(t). But the plot doesn't look like a plot of t/4 + C1 * cos(2t) -C2*sin(2t), which is x(t). For example, if C1 and C2 are set equal to 1 a different plot is generated. How is the Simulink plot to be interpreted? No initial conditions are specified and it appears that x(0) = 0 and x'(0) = 0 are assumed but it seems that with these initial conditions the differential equation has no solution because the output of Matlab when I specified these initial conditions, or only the condition x(0) == 0, to solve the differential equation with dsolve was empty.

回答(1 个)

Tushar Behera
Tushar Behera 2022-10-6
Hi Aleem Andrew,
I believe you are trying to implement t-4x(t)=x’’(t) in Simulink.
Your model seems to be correct, and the Simulink engine is trying to solve the equation with default initial conditions as x(0)=0 and x’(0)=0. The output for x(t) for the above differential equation seems to be as below,
This is the curve for the equation x(t)=t/4-sin(2*t)/8. This can be further verified by using “dsolve” for solving the above said equation.
syms x(t) a b
eqn = diff(x,t,2) == t-4*x;
Dx = diff(x,t);
cond = [x(0)==0, Dx(0)==0];% initial condition x(0)=0 and x’(0)=0
xSol(t) = dsolve(eqn,cond);
t=1:0.2:10;
plot(xSol(t))
The solution x(t)= t/4 + C1*cos(2*t) - C2*sin(2*t) is when initial conditions are not present for the differential equation. That’s why the plot seems different as it’s for x(t)=t/4-sin(2*t)/8. I hope this helps resolve your query.
Here is the link for additional documentation:
Thanks and regards,
Tushar Behera

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by