Info

This question is closed. Reopen it to edit or answer.

Selecting Elements of an Array in Simulinks Based on Simulation Time

1 view (last 30 days)
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.

Answers (1)

Raj
Raj on 17 May 2019
Edited: Raj on 17 May 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.

Products

Community Treasure Hunt

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

Start Hunting!