How do I changing file name in a "To File" block in Simulink from matlab command window?

Hi, Is there a way that i can change the file name in a "To File" block in Simulink from Matlab?
To change a variable in a "Constant" block the following line works.
set_param('model/Constant1','Value','5')
However changing the file name in a "To File" block using the same approach results in an error: "Invalid Simulink object specifier"
The input I have used is:
set_param('model/To File','FileName','test.mat')
Any solutions to this problem would be appreciated, as well as more efficient alternatives to use.
I'm running Matlab R2013b.

 Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 4 Feb. 2014
Bearbeitet: Sean de Wolski am 4 Feb. 2014
You can use gcb to get the current block:
set_param(gcb,'filename','hello_world.mat')
And to see the name of the block:
'amodel/To File'

Weitere Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by