How can I close the report window after code generation using rtwbuild() for a Simulink model from the command line? - matlab

I'm trying to automate the building process of my Simulink models. I achieve to handle the configuration of these models as I want.
Then I start generation using the command :
rtwbuild('system', 'Mode', 'ExportFunctionCalls');
That's working pretty well. At the end of the generation, a window appears showing a report of the generation allowing me to browse the just generated code.
My script builds several models and I would like to close this window after each model generation in order to don't disturb the user with all those reports "poping out".
An even better solution would be to not even show this window. I don't need to see it in my generation process and I don't want the user to click the OK button for each report.
So, is there a way to prevent rtwbuild() command to show this report when it's done ? Or at least, is there a way to close this window from the command line after the generation ?

As suggested by #Navan in the comments, there is a model parameter for that.
So to disable the generation of the report (and therefore the opening of the report window), you can simply use the command :
set_param(system, 'GenerateReport', 'Off')
I also got some more information from the MATLAB support. It is also possible to generate this report but prevent the window from opening using these commands :
set_param(system, 'GenerateReport', 'On')
set_param(system, 'LaunchReport', 'Off')
I was using MATLAB R2011a. But since R2012, there are some dedicated methods to open/close code report :
coder.report.open
coder.report.close()

Related

Matlab - replace classification layer using a script (automatically)

i want to train a neural network with flexible output size. In the beginning, i used the matlab deep network designer to manually replace the classification and fully connected layer to the desired output size. Now, i want to automatically replace it, using a script.
Which command is working for that?
Simply trying the line:
net.Layers(142,1).InputSize = 10;
gives me the error message
Unable to set the 'InputSize' property of class 'FullyConnectedLayer' because it is read-only.
Trying to replace the complete layer (not only inputsize) is resulting in the same error message.
Is this possible with matlab, and if yes, which commands will do the job?
Thanks in advance!
Okay, i think i solved it. When changing the network manually inside of the deepnetworkdesigner, there is the possibility to click "export code" which exports the desired code for the adapted output size

Is there a way to execute MATLAB Figure window menu items via command?

I found a neat bit of code for setting drawing tools via callback:
draw.m .
Edit
My apologies - I didn't realize that the Name property was a red herring - it is the annotation call that enables drawing the various figures.
So my corrected question is: is there a way to execute other menu item commands, such as set(gcf,'Some_property','Rotate 3D') ?
The easiest way to execute a menu item's command is to get a handle to the menu item and then inspect the Callback property to see what it calls internally.
rotate_menu = findall(gcf, 'type', 'uimenu', 'tag', 'figMenuRotate3D');
rotate_menu.Callback
% 'toolsmenufcn Rotate'
As you can see this uses an internal function toolsmenufcn which we could call directly to activate the tool.
toolsmenufcn(gcf, 'Rotate')
If you actually look at the contents of toolsmenufcn.m (edit toolsmenufcn), you will see a list of all available commands.
Using the toolsmenufcn directly is of course undocumented so use at your own risk. On the other hand, dynamically retrieving and executing the Callback for the menu should work across versions.

How to save mpi profile summary report in matlab

I want to save the details of each worker as it is seen in the mpiprofile summary report. Profsave does not give all the details very clearly for the report generated by the mpiprofile viewer option.
Is there any other way to save the report?
One way I figured to do something similar is the following.
I am assuming you are using "pmode" because as far as my understanding goes, you need to run on "pmode" to run mpiprofile.
So this is how it goes.
Saving
Save the mpiprofile info inside each worker(or it is often called lab from my understanding).
mpiprofile mpistruct;
Then you transfer to the client using the following command
pmode lab2client mpistruct;
Then save the mpistruct into a .mat file
save('mpistruct');
Loading:
When you are trying to view the mpiprofile result:
Load the mpi file
load('mpistruct.mat');
Run mpiprofile viewer
mpiprofile('viewer', mpistruct);
This should pop up the browser.
Note. Above code was tested with 2015b.
(I wrote the same exact answer to Matlab community. I copied for your convenience.)

MATLAB Automate GUI

I currently have a GUI that outputs a single text file based on various input parameters. However, I need to modify my application such that the GUI outputs multiple text files based on N inputs. The original GUI designer is no longer available and the main m-file has over 5k lines of code making it difficult to troubleshoot (not to mention the code is very unorganized and not commented). Does anyone have any suggestions on how I can run the GUI N times based on the N inputs and output N text files without modifying the original m-file?
Assume your gui is called myApp and your callback to s called myButton_Callback.
I also assumng that the tag of the uicontrol is 'myButton'.
Here is the caller script:
myApp_h = myApp();
myApp_handles = guidata(myApp_h);
myButton_h = myApp_handles.myButton;
MyApp('myButton_Callback', myButton_h, myApp_handles);
You can automate any gui control by this method.

Data.c file generation

i'm very new to matlab, i'm working on a software which needs the following files as input model.c,model.h,model_data.c for a particular simulink model. I have a model for which i can't generate model_data file using RTW, i have tried to get some information on the files generated by RTW, but i didnt get sufficient info. If there anybody who knows about the RTW please let me know the blocks which are required to generate model_data.c
thank you
model_data.c is a conditionally created file (i.e. it is only created if it is needed, which depends on the way the model is set up for code generation).
For a discussion of the Simulink Coder build process, and what files get generated when, search the doc for the section titled "Files and Folders Created by Build Process".
For others who need help in future.
Open the Configuration Parameters pane. Go to Code Generation -> Optimization and make sure that Default parameter behavior is set to Tunable.