Is there any way to perform an at least partially symbolic smulation (using ODE or discrete model) in simulink?

1 次查看(过去 30 天)
Does it exst any way to use symbolic variables for paraametrzng a simulink model and getting a symbolic or semi symbolic solution?

回答(2 个)

Walter Roberson
Walter Roberson 2024-10-5
If you turn rapid acceleration off, and use coder.extrinsic then you can include symbolic calculations within any one MATLAB Function Block. However, you cannot pass symbolic results as signals between blocks, and you need to convert any results back from symbolic to double before emitting them from the block.
I suspect also that you cannot declare symbolic values as global or persistent
  7 个评论
Walter Roberson
Walter Roberson 2024-10-6
Simulink is designed to produce numeric solutions, not parametric solutions.
At any one time, Simulink signals are numeric and have specific values.
There are ways in Simulink to create constructs that adapt to changes in input signals, so it is often possible to "tune" models -- but still at any time all signals have specific numeric value. Simulink is not doing any kind of symbolic manipulation or analysis to tune models; it is strictly varying numeric parameters.
Paul
Paul 2024-10-6
编辑:Paul 2024-10-6
Let's suppose Simulink could do what you want, at least my interpretation of what I think you're asking for.
Here's the second order model with all parameters and initial conditions symbolic, and simulating it as Simulink would for the simplest possible integration scheme.
syms M K C x0 xdot0 x real
% M xddot + c*xdot + K*x = 0;
%x1 = x;
%x2 = xdot;
%X1dot = x2;
%x2dot = (-C*x2 - K*x1)/M;
t = 0;
dt = 0.1;
x = [x0;xdot0];
for ii = 1:10
xdot = [x(2); -(C*x(2) - K*x(1))/M];
x = x + dt*xdot;
t = t + dt;
end
x = simplify(x)
That results doesn't look very useful. Imagine how complex it would look using a more complicated integration, or if the model itself was even marginally more complicated. Nevermind all of the the other stuff that Simulink has to deal with, like inequalities, event detection, etc. Basically, Simulink is not the tool you're looking for.
I agree with your point, but Simulink signals don't have to be numeric. Simulink supports string and boolean and enumerated types, though it's quite possible that the latter two are implemented under the hood with numerics.
edit: I guess Answers is still suffering from not rendering symbolic output. I wonder what happened and why it's taking so long to fix. @Tushal Desai

请先登录,再进行评论。


John D'Errico
John D'Errico 2024-10-6
编辑:John D'Errico 2024-10-6
Essentially, no. This is a frequent question about tools like ODE45 too. Simulink is a purely numerical tool, like ODE45 and other numerical solvers. You cannot parameterize a problem in terms of symbolic unknown parameters.
Can you perform symbolic computations inside a function that Simulink may employ? Well, yes. But I think that is not the gist of your question. Simulink does not return a solution in a functional form. It is a simulation tool.

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by