Store "From Workspace" Variable into array in Simulink

17 vues (au cours des 30 derniers jours)
Andreas Harter
Andreas Harter le 14 Juil 2016
Commenté : Andreas Harter le 18 Juil 2016
My Simulation get's an array as input from the workspace. How can I store the last 100 of these values in a [100 1]-array and send them to a function for further calculation? I tried GoTo-Tags, Data-Memory-Blocks and Embedded Functions but it doesn't seem to work.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 14 Juil 2016
Use matlab function block with this code
function y = fcn(u)
%#codegen
persistent k z
n=10
if isempty(k)
k=0
z=zeros(1,n);
end
z=[z(2:n) u]
y=z
%
  1 commentaire
Andreas Harter
Andreas Harter le 18 Juil 2016
Thank you, "persistent" did the trick!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Modeling 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!

Translated by