How to give a vector as input in Simulink, to solve a system of differential equations ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to solve the following system of differential equations. It mathematically describes a 2-DOF car model and it's a very common problem in scientific literature. I managed to solve it using DotNumerics library from C# but I would like to solve it using Matlab, as well. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1285040/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1285040/image.png)
From which:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1285045/image.png)
So, I have tried to do it using Simulink and I have build the attached block diagram to solve the system.
The 'y' from the system represents the road, which I generated as an array of values using ISO 8608 standard, in a Matlab script.
The prolem is that I don't know how to give this array I generated as input to the attached Simulink model, below. I have to do this because the road is a function of time, so that in each moment of the time the excitation of the road is different.
I used a constant block with a constant value, temporarly, and I also tried to give the name of the array to this block, but certainly, these are not solutions to my problem.
Could you please help me to figure this out ? I have seen a few vague indications in some papers but nothing practical to solve my issue.
Maybe, I could consider to tackle the problem from a different angle by using some Matlab script libraries, instead. Nevertheless, any solution or example would be appreciated.
Thanks in advance.
4 commentaires
Paul
le 5 Fév 2023
I'm afraid I have to repeat my questions.
Are the values in the y-array samples of a function of time? If not, what is the independent variable?
I don't know anything about the C# implementation and so don't know what it assumed to solve the problem. In Simulink, solving a continuous-time system requires the solver to evaluate the inputs to the integrators at any instant in time. In this case, you have a discrete set of samples in the y-array of what is fundamentally a continous function, the road (I assume that's the height of the road above some baseline level). So, you'll need to decide how Simulink should compuate "the road" in between the samples provided in the y-array. You could assume that the road is constant in between samples, but that would lead to discontinuities in the road height, which sounds like a very bad road. You could assume the road is linearly interpolated between the samples, but then you'd have a discontinuous first derivative, which might not be realisitic either.
So, you'll need to specify how to model the road between samples of its independent variable and what that independent variable is before you can any further.
Réponse acceptée
Paul
le 5 Fév 2023
Use the y-array and its corresponding times to specify the table data.
Use the other block parameters to specify the interpolation method and how you want the block to behave if it has to extrapolate off the end of the y-array.
If the y-array data are at equally spaced points in time, there are some other options to use in that block to make the lookup more efficient.
4 commentaires
Paul
le 7 Fév 2023
Simulation time starts at T=0. If that table lookup is called before T = 1, make sure to set the Extrapolation method parameters appropriately. If you really have 1000 evenly spaced points starting at t = 0, enter the breakpoints as 0:999. Or, set the Breakpoint Specification to 'even spacing' and set First Point to 0 and Spacing to 1.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Event Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!