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

4 views (last 30 days)
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.

Accepted Answer

Sean de Wolski
Sean de Wolski on 4 Feb 2014
Edited: Sean de Wolski on 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'

More Answers (0)

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!