From: Tim on
I am trying to use the saveas function on a simulink model after it has been opened.

saveas(modelhandle,filename,format)

The problem is I can't find a decent way to retrieve the model handle. I was hoping something like this would work...

modelhandle = open_system(modelname)

But the open_system function doesn't return a handle. I can find the hadle using the gui but not programatically. By using inspect(gcbh), and then finding the parent entry and expanding it, then finding the handle entry. But programatically you can't do this because.

get(gcbh,'Parent')

ans =

model_name

So I tried some other things, thinking I've missed something about how the models are treated by the matlab environment. I found this and thought it would work, no such luck...

metadata = Simulink.MDLInfo('modelname')

It seems like this should be really simple.
From: Donn Shull on
"Tim " <timerbes(a)gmail.com> wrote in message <huo8n3$t5h$1(a)fred.mathworks.com>...
> I am trying to use the saveas function on a simulink model after it has been opened.
>
> saveas(modelhandle,filename,format)
>
> The problem is I can't find a decent way to retrieve the model handle. I was hoping something like this would work...
>
> modelhandle = open_system(modelname)
>
> But the open_system function doesn't return a handle. I can find the hadle using the gui but not programatically. By using inspect(gcbh), and then finding the parent entry and expanding it, then finding the handle entry. But programatically you can't do this because.
>
> get(gcbh,'Parent')
>
> ans =
>
> model_name
>
> So I tried some other things, thinking I've missed something about how the models are treated by the matlab environment. I found this and thought it would work, no such luck...
>
> metadata = Simulink.MDLInfo('modelname')
>
> It seems like this should be really simple.

Try this:

load_system('model_name')
modelhandle = get_param('model_name', 'Handle')
saveas(modelhandle, 'myfile.bmp')
close_system('model_name')

good luck,

Donn
From: Tim on
"Donn Shull" <donn.shull.no_spam(a)aetoolbox.com> wrote in message <huohu1$mvs$1(a)fred.mathworks.com>...
> "Tim " <timerbes(a)gmail.com> wrote in message <huo8n3$t5h$1(a)fred.mathworks.com>...
> > I am trying to use the saveas function on a simulink model after it has been opened.
> >
> > saveas(modelhandle,filename,format)
> >
> > The problem is I can't find a decent way to retrieve the model handle. I was hoping something like this would work...
> >
> > modelhandle = open_system(modelname)
> >
> > But the open_system function doesn't return a handle. I can find the hadle using the gui but not programatically. By using inspect(gcbh), and then finding the parent entry and expanding it, then finding the handle entry. But programatically you can't do this because.
> >
> > get(gcbh,'Parent')
> >
> > ans =
> >
> > model_name
> >
> > So I tried some other things, thinking I've missed something about how the models are treated by the matlab environment. I found this and thought it would work, no such luck...
> >
> > metadata = Simulink.MDLInfo('modelname')
> >
> > It seems like this should be really simple.
>
> Try this:
>
> load_system('model_name')
> modelhandle = get_param('model_name', 'Handle')
> saveas(modelhandle, 'myfile.bmp')
> close_system('model_name')
>
> good luck,
>
> Donn

Thanks! I knew it would be simple.

It seems like the help doc of 'get' should include 'get_param' under the 'see also' section.
 | 
Pages: 1
Prev: binning data
Next: Deconvolution following fft