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 vue (au cours des 30 derniers jours)
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 commentaires
Adrian Kaessens
Adrian Kaessens le 8 Juin 2022
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 le 8 Juin 2022
Modifié(e) : Siddharth Kamila le 8 Juin 2022
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)

Connectez-vous pour commenter.

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 8 Juin 2022
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 commentaires
Siddharth Kamila
Siddharth Kamila le 13 Juin 2022
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.
Fangjun Jiang
Fangjun Jiang le 13 Juin 2022
At the triggered subsystem, choose "function call" as the trigger.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by