Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Simulink Report Generation from the Command Line

Subject: Simulink Report Generation from the Command Line

From: Eric Brewer

Date: 26 Feb, 2010 15:03:04

Message: 1 of 8

I am trying to generate Simulink reports from the command line using a given template (.rpt) file. I have a report template (ReportTemplate.rpt) and a Simulink model (model.mdl). In the command line, if I type "report model", I get the standard full report for the model. If I type "report ReportTemplate", I will only get a report on my model using the template if the model is opened, otherwise I get a report for a standard simulink blockset. Is there a way to generate a report for "model.mdl" using the template without opening the model? Thanks in advance!

-Eric

Subject: Simulink Report Generation from the Command Line

From: Arkadiy Turevskiy

Date: 1 Mar, 2010 22:27:04

Message: 2 of 8

My guess is that your ReportTemplate.rpt is based on some standard shipping report template files, like simulink-default.rpt

The first component of your rpt file is probably if component ith this text expression:
isempty(find_system('SearchDepth',1,'BlockDiagramType','model'))

The second component is probably Evaluate MATLAB Expression with this code:

%if no models are open, open f14
f14

The combined effect of these two components is to see if any model is open when you execute a report, and if not, to open f14 model by default.

To open your model if no models are open simply change the code in Evaluate MATLAB Expression component to:

%if no models are open, open model
model

Hope this helps. Let me know if this helped or if something else is happening.
Arkadiy


"Eric Brewer" <piano_man354@yahoo.com> wrote in message <hm8nr8$69u$1@fred.mathworks.com>...
> I am trying to generate Simulink reports from the command line using a given template (.rpt) file. I have a report template (ReportTemplate.rpt) and a Simulink model (model.mdl). In the command line, if I type "report model", I get the standard full report for the model. If I type "report ReportTemplate", I will only get a report on my model using the template if the model is opened, otherwise I get a report for a standard simulink blockset. Is there a way to generate a report for "model.mdl" using the template without opening the model? Thanks in advance!
>
> -Eric

Subject: Simulink Report Generation from the Command Line

From: Eric Brewer

Date: 2 Mar, 2010 18:10:23

Message: 3 of 8

"Arkadiy Turevskiy" <arkadiy.turevskiy@mathworks.com> wrote in message <hmhevo$qae$1@fred.mathworks.com>...
> My guess is that your ReportTemplate.rpt is based on some standard shipping report template files, like simulink-default.rpt
>
> The first component of your rpt file is probably if component ith this text expression:
> isempty(find_system('SearchDepth',1,'BlockDiagramType','model'))
>
> The second component is probably Evaluate MATLAB Expression with this code:
>
> %if no models are open, open f14
> f14
>
> The combined effect of these two components is to see if any model is open when you execute a report, and if not, to open f14 model by default.
>
> To open your model if no models are open simply change the code in Evaluate MATLAB Expression component to:
>
> %if no models are open, open model
> model
>
> Hope this helps. Let me know if this helped or if something else is happening.
> Arkadiy
>
>
> "Eric Brewer" <piano_man354@yahoo.com> wrote in message <hm8nr8$69u$1@fred.mathworks.com>...
> > I am trying to generate Simulink reports from the command line using a given template (.rpt) file. I have a report template (ReportTemplate.rpt) and a Simulink model (model.mdl). In the command line, if I type "report model", I get the standard full report for the model. If I type "report ReportTemplate", I will only get a report on my model using the template if the model is opened, otherwise I get a report for a standard simulink blockset. Is there a way to generate a report for "model.mdl" using the template without opening the model? Thanks in advance!
> >
> > -Eric

Arkadiy,
Thanks for the response. Unfortunately, I can't find the if statements that you mention. Also, I believe this would make the template specific to one model. Is there any way to pass in the model name to a function, such that I can generate the report from this template regardless of the model name? Thanks in advance.

-Eric

Subject: Simulink Report Generation from the Command Line

From: Arkadiy Turevskiy

Date: 2 Mar, 2010 19:17:06

Message: 4 of 8

if you have a model file model.mdl and report setup file reportcustom.rpt,

>>myreport('model','reportcustom.rpt')

where

function [ ] = myreport(mymodelname,myreportname)
% Model must be loaded.
load_system(mymodelname)
% Associate model with report name. Needs to be done once if saved.
set_param(mymodelname,'ReportName',myreportname)
save_system(mymodelname);
% Generate report.
report(mymodelname)
close_system(mymodelname)
end

Arkadiy

> Arkadiy,
> Thanks for the response. Unfortunately, I can't find the if statements that you mention. Also, I believe this would make the template specific to one model. Is there any way to pass in the model name to a function, such that I can generate the report from this template regardless of the model name? Thanks in advance.
>
> -Eric

Subject: Simulink Report Generation from the Command Line

From: Eric Brewer

Date: 2 Mar, 2010 19:55:06

Message: 5 of 8

"Arkadiy Turevskiy" <arkadiy.turevskiy@mathworks.com> wrote in message <hmjo7h$il5$1@fred.mathworks.com>...
> if you have a model file model.mdl and report setup file reportcustom.rpt,
>
> >>myreport('model','reportcustom.rpt')
>
> where
>
> function [ ] = myreport(mymodelname,myreportname)
> % Model must be loaded.
> load_system(mymodelname)
> % Associate model with report name. Needs to be done once if saved.
> set_param(mymodelname,'ReportName',myreportname)
> save_system(mymodelname);
> % Generate report.
> report(mymodelname)
> close_system(mymodelname)
> end
>
> Arkadiy
>
> > Arkadiy,
> > Thanks for the response. Unfortunately, I can't find the if statements that you mention. Also, I believe this would make the template specific to one model. Is there any way to pass in the model name to a function, such that I can generate the report from this template regardless of the model name? Thanks in advance.
> >
> > -Eric

That's exactly what I was looking for. Thanks!

Subject: Simulink Report Generation from the Command Line

From: Eric Brewer

Date: 2 Mar, 2010 21:17:02

Message: 6 of 8

"Eric Brewer" <piano_man354@yahoo.com> wrote in message <hmjqeq$eb6$1@fred.mathworks.com>...
> "Arkadiy Turevskiy" <arkadiy.turevskiy@mathworks.com> wrote in message <hmjo7h$il5$1@fred.mathworks.com>...
> > if you have a model file model.mdl and report setup file reportcustom.rpt,
> >
> > >>myreport('model','reportcustom.rpt')
> >
> > where
> >
> > function [ ] = myreport(mymodelname,myreportname)
> > % Model must be loaded.
> > load_system(mymodelname)
> > % Associate model with report name. Needs to be done once if saved.
> > set_param(mymodelname,'ReportName',myreportname)
> > save_system(mymodelname);
> > % Generate report.
> > report(mymodelname)
> > close_system(mymodelname)
> > end
> >
> > Arkadiy
> >
> > > Arkadiy,
> > > Thanks for the response. Unfortunately, I can't find the if statements that you mention. Also, I believe this would make the template specific to one model. Is there any way to pass in the model name to a function, such that I can generate the report from this template regardless of the model name? Thanks in advance.
> > >
> > > -Eric
>
> That's exactly what I was looking for. Thanks!

I just noticed that occasionally (maybe 1 in 10) the command "myreport(mymodelname,myreportname)" will still generate a random report for dpstat30, or eml0, instead of mymodelname. Is this a bug? Thanks in advance.

Subject: Simulink Report Generation from the Command Line

From: Arkadiy Turevskiy

Date: 2 Mar, 2010 22:50:21

Message: 7 of 8

Hard to say what is going on without having all your files. You can submit a help request and tech support will help you:
http://www.mathworks.com/support/product/product.html?product=SR
the link that says "create a new service request".
Arkadiy


> I just noticed that occasionally (maybe 1 in 10) the command "myreport(mymodelname,myreportname)" will still generate a random report for dpstat30, or eml0, instead of mymodelname. Is this a bug? Thanks in advance.

Subject: Simulink Report Generation from the Command Line

From: Arkadiy Turevskiy

Date: 2 Mar, 2010 23:18:04

Message: 8 of 8

Oy you could try a simpler code that should work as well assuming you use Model Loop component whci is set to report on current block diagram:

function [ ] = myreport(mymodelname,myreportname)
   load_system(mymodelname)
   report(myreportname)
   close_system(mymodelname)
end

Also use different names for a Simulink model and for .rpt file.

Arkadiy

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us