How can I use a variable to set the file name using Simulink's "too file" block?

8 ビュー (過去 30 日間)
Ajay Mehta
Ajay Mehta 2022 年 9 月 13 日
回答済み: Fangjun Jiang 2022 年 9 月 14 日
I am using Matlab 2020a to create a model and place the pertaent data into a file. My plan is to automate running the model via Matlab. Each time the model is run via Matlab certain variables in the model are changed. This has worked perfectly thus far with the exception of changing the name of the data file writen via simulink's "too file" function. If I set the variable A="" in matlab and set the file name field in "too file" to A (note the lack of quotes), the resulting file created will be called "" rather than "". I do not know how to fix this issue.
If this is a bug that is fixed in newer versions of Matlab please let me know as I do have access to the latest release but have not updated.
Thank you,
Ajay Mehta

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2022 年 9 月 14 日
As for as I know, what you imagined can not be done. In your MATLAB script, you have to modify the parameter of the "ToFile" block to change the file name. Including this in the loop of your script should be able to achive what you want.


Find more on Simulink in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by