How to create a running window inside simulink model in MATLAB/Simulink that can take some sample of input data at every 0.05 sec time instance & feed to the MATLAB program ?

조회 수: 1 (최근 30일)
I have simulated a model in MATLAB/Simulink, in which there is a MATLAB fcn block (MATLAB fcn block is available in simulink library browser, you can check it) inside which there is a program code, which accepts input data and converts it into its respective output, according to the code logic. Here while running the simulation from 0 sec to 5 sec, the matlab program code inside the Matlab fcn block, continuously accepts the input data and gives the output, according to the code logic. But, I want that the matlab code should take some samples of input data every 0.05 sec instance and converts it into the respective output. In the next 0.05 sec time instance, the matlab code will take next samples of input data and convert it into the respective output (thus creating a running window at every 0.05 sec time instance), and in this way the process goes on till the simulation time is over (from 0 sec to 5 sec). What is the code syntax to be added, in the existing program, so that the above can be achieved ?
I just want some suggestions, I am not asking for an exact answer ?
  댓글 수: 2
Adrian Kaessens
Adrian Kaessens 2022년 6월 8일
Hey,
in what form is your input data available?
if its coming from Matlab, you could create a structure format providing the TimeValues & DataValues and use that with the simin block.
If its a continuous signal but you're only concerned about your fcnBlock running every 0.05 seconds, you can just set the sample time of that block to 0.05.
Siddharth Kamila
Siddharth Kamila 2022년 6월 8일
편집: Siddharth Kamila 2022년 6월 8일
Input data is available in the form of waveform of AC fault line current which is displayed on the scope in simulink model. This AC fault line current is sensed from the simulink model of power system created in simulink. The AC fault line current waveform is continuous and sinusoidal. (I hope you know about the scope used in simulink and the waveform which is displayed in the scope)

댓글을 달려면 로그인하십시오.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2022년 6월 8일
This is the fundermental basic of the Simulink simulation.
If nothing is constrained, set the solver to be discete, with fixed step size of 0.05, then everything (including the MATLAB Function block) is calculated (executed) at every 0.05 second. It takes 100 steps to finish the 0 to 5 second simulation.
If the solver and stepsize have to be something else, then put the MATLAB Function block inside a triggered subsystme, Use a Function Call Generator block to trig the subsystem, set the "sample time" of the Function Call Generator to be 0.5. Then the MATLAB Function block is executed every 0.05 second.
  댓글 수: 2
Siddharth Kamila
Siddharth Kamila 2022년 6월 13일
It is showing, "Invalid "function-call" connection" as error after I used function call generator and set the sample time as 0.05, and connected to the triggered subsystem.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by