In my Simulink model I would like to conditionally write output data to selectable .mat files in different relative directories.

5 ビュー (過去 30 日間)
I have attempted to use a 'Switch Case' block with several 'Switch Case Action Subsystem' blocks, each containing a 'To File' block specifying a different relative directory and filename (.MAT). Unfortunately Simulink initializes empties (re-initializes) the MAt files specified in the non active Cases each run.
  1 件のコメント
Mark Wilson
Mark Wilson 2019 年 12 月 18 日
My question is How do I prevent Simulink from re-initializing the inactive case 'To File' blocks ?

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

採用された回答

Jim Riggs
Jim Riggs 2019 年 12 月 18 日
This sounds like a rather sophisticated way of constructing output. I'm not sure if that is easily acomplished with the "to file" block. I like to use S-functions to control my output.
In fact, I have an S-function that is the first block to run in my model (this is accomplished by placing it at the top level of the model and assigning it a priority = 1). this block reads a number from a file called "serialNumber", increments the number, and saves the incremented number bask to the "serialNumber" file. This serial number is used in other S-functions that generate output files, and appended to the output file name, so that every time I run the model the output is recorded in a new file with a "run number" attached to the file name. I can keep a log of all of the runs (date, time, run parameters), and pull up results for comparison (by run number) later. In fact, you can have the S-function that reads the serial number keep the run log in a file for you.
  1 件のコメント
Mark Wilson
Mark Wilson 2019 年 12 月 18 日
Thank You Jim.
A very useful suggestion. I am now convinced that I cannot use the To File block as I am doing in Case Switch Action blocks.
Best Regards, Mark.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrepare Model Inputs and Outputs についてさらに検索

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by