Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Selecting Elements of an Array in Simulinks Based on Simulation Time

조회 수: 1 (최근 30일)
Thomas Carlson
Thomas Carlson 2019년 5월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
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.

답변 (1개)

Raj
Raj 2019년 5월 17일
편집: Raj 2019년 5월 17일
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.

Community Treasure Hunt

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

Start Hunting!

Translated by