Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Selecting Elements of an Array in Simulinks Based on Simulation Time

1 Ansicht (letzte 30 Tage)
Thomas Carlson
Thomas Carlson am 17 Mai 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hello,
I am creating a simulation of a quarter car model which I wish to disturb with a displacement of the wheel. I have imagined a speedbump whose equation behaves roughly as follows:
%y = -4.444x^2 + 1.333x
%dy = -8.888x + 1.333
In a for loop I have placed values from these equations into two arrays and I wish to have my model run in such a way that it selects a new element as an input every so often. I tried to figure out how to do using the selector block, but I cannot seem to get a grasp on what input it requires to make a selection.

Antworten (1)

Raj
Raj am 17 Mai 2019
Bearbeitet: Raj am 17 Mai 2019
Since you have not shared your model, its difficult to give a precise answer. I assume you must be using user defined matlab function block in your model. Save your data (obtained from the two equations) in workspace as a time series in steps of your model simulation step time. Then you can can pass these two parameters as an input to the function using inports. Make sure you set the configuration parameter under Data Import/Export correctly. Now there is no need for the 'for' loop as data corresponding to each step time only will be used by the function as simulation progresses. I have tried to make sense but if it sounds confusing then get back and share your model along with data.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by