Azzera filtri
Azzera filtri

How to give a vector as input in Simulink, to solve a system of differential equations ?

5 visualizzazioni (ultimi 30 giorni)
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.
From which:
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 Commenti
Paul
Paul il 5 Feb 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.
Patrausanu Andrei
Patrausanu Andrei il 5 Feb 2023
I see what you mean. The values in the y-array are generated by a continuous function of time. The time is clearly the independent variable, as you also said. Regarding the interpolation, I would preffer to use the spline interpolation. Maybe, in the future, I may change it to linear, even though it has the drawbacks you talked about. Considering these two theoretical aspects clarified, how shall I proceed ? How can apply it in Simulink ? So far, as you can see in the atached Simulink file, I have been able to give Simulink only one constant value from the y-array.

Accedi per commentare.

Risposta accettata

Paul
Paul il 5 Feb 2023
Use a 1-D Lookup Table block with a Clock connected to its input.
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 Commenti
Patrausanu Andrei
Patrausanu Andrei il 7 Feb 2023
In the LookUpTable block, I get my road vector. It is displayed correctly so I guess it should be ok. I was wondering about Breakpoints section. I gave it the time as [1:1000]. I always generate my time aray from 1 to 1000. My road array always have 1000 points. Is it correct ? Moreover, I was wondering about something else. I would have expected to see some other results, but it could be something wrong with my block diagram. If the road is properly given as input to it, and I guess it is, then it must be a problem with what I did. Thank you!
Paul
Paul il 7 Feb 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Event Functions in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by