How can i hold on output to run a matlab function with it during simulation ?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
K G
le 18 Juil 2019
Réponse apportée : Samatha Aleti
le 2 Août 2019
I have an output of a model in simulation a voltage(rectangular) and i need it as in input in a matlab function with in the simulation model to run , how do i store it ? i tried a buffer an zero holder but i cant store or hold on all the values
3 commentaires
Réponse acceptée
Samatha Aleti
le 2 Août 2019
Hi,
According to my understanding you want to store the output of each step simulation and want to access it in MATLAB Function block during the simulation. One of the ways you can do is to connect the Output with a delay block as one of the inputs to MATLAB function block and use persistent vector in MATLAB function to store each output.
If the MATLAB function has to perform functions based on simulation time, you can use clock block in SIMULINK model.
You can refer the attached model and MATLAB function as an example.
function y = fcn(~, data)
persistent CP
if(isempty(CP))
CP = 0;
else
CP = [CP data];
end
y = CP(end);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Signal Generation, Manipulation, and Analysis 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!