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.

 Respuesta aceptada

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'

Más respuestas (0)

Categorías

Más información sobre Simulink en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 4 de Feb. de 2014

Comentada:

el 4 de Feb. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by