# Plotting solutions of differential equations in Simulink

8 visualizaciones (últimos 30 días)
Aleem Andrew el 27 de En. de 2021
Respondida: Tushar Behera el 6 de Oct. de 2022
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.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Tushar Behera el 6 de Oct. de 2022
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.
Thanks and regards,
Tushar Behera
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by