Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Selecting Elements of an Array in Simulinks Based on Simulation Time

1 vue (au cours des 30 derniers jours)
Thomas Carlson
Thomas Carlson le 17 Mai 2019
Clôturé : MATLAB Answer Bot le 20 Août 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.

Réponses (1)

Raj
Raj le 17 Mai 2019
Modifié(e) : Raj le 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.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by