Store "From Workspace" Variable into array in Simulink

16 ビュー (過去 30 日間)
Andreas Harter
Andreas Harter 2016 年 7 月 14 日
コメント済み: Andreas Harter 2016 年 7 月 18 日
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.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 14 日
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 件のコメント
Andreas Harter
Andreas Harter 2016 年 7 月 18 日
Thank you, "persistent" did the trick!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by