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)
Afficher commentaires plus anciens
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
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.
Réponses (1)
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
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!