Using dynamic workspace arrays as Matlab function input/output

1 回表示 (過去 30 日間)
Niklas Braun
Niklas Braun 2020 年 11 月 30 日
回答済み: Fangjun Jiang 2020 年 12 月 1 日
Hey there,
i want to create a Simulink model, where the following happens:
  1. Based on Simulink signal values as input, an array of possible responses shall be created/extended in Matlab base workspace. If the input signals do not change in between simulation steps, the array shall not be extended.
  2. After that, a separate Matlab function Block should choose values from this array, process them and create Simulink output values. The values, which were used to generate the output values shall be removed from the list (or marked as used)
So far, I have created a Matlab function block, which takes the simulink signal, as well as a constant, which points to the list in the Matlab workspace, as input. And outputs the updated list. How can i write the updated list in the workspace?
  2 件のコメント
Fangjun Jiang
Fangjun Jiang 2020 年 11 月 30 日
Why involve MATLAB base workspace? The interface between your part 1 and part 2 could be an ordinary signal, a vector signal or array signal.
Niklas Braun
Niklas Braun 2020 年 12 月 1 日
Thanks for the hint.
So i could use the array as Input and Output of part 1 and part 2 Matlab function blocks and then loop it pack to part 1 with a memory block in between?
Is it possible to have variable array length in that configuration, or has the initial memory value to specify the later array size?

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

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 12 月 1 日
  1. Use vector signal between part 1 and part 2. No need to use memory block. Use Unit delay to resolve algebric loop if needed.
  2. Use global variable if don't want to bother the signal interface. See https://www.mathworks.com/help/releases/R2020b/simulink/ug/using-global-data-with-the-matlab-function-block.html
  3. variable-size signal is supported

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by