MATLAB: Changing plotperform window name, and more - matlab

So I'm working on some simple neural network problems for a class I'm taking, and I've mostly done all of the work.
However, I'd like to be able to press run and have all of the relevant figures and graphs pop out so I can easily show my work.
To do this I've been drawing setting the names of figures that I plot in using the
figure('Name', 'NameGoesHere', 'NumberTitle', 'off')`
variant of the figure function.
The thing is, one of the things that I have to show are performance graphs for the different networks I made, and using plotperform(tr) sets the window name to Performace (plotperform) even if I try setting the figure name to something else. Any help?
Here's a picture showing what I mean:
Oh, and, being really new to Matlab, correct me if I'm wrong, but since performance is defined as mean absolute error, the lower it is, the better right? So is there a way to set is so plotperform actually selects the lowest point of the graph as the best instead of the first one?
Another thing I'd like to be able to do is have the training information nntraintool open in a new window every time I call the train(netA, P, T) function. Right now, every time it's called it just overwrites the previous info in the nntraintool window. Is it even possible to do this?
This is the window I'm talking about:

Related

Matlab: Export a figure made with myaa

I am trying to get better quality phase plots of complex functions made with the Complex Function Explorer of E. Wegert CFE. For this purpose I apply the Matlab anti-aliasing function myaa.m to the phase plots that are made with the CFEGUI.m. For the example screenshot of the result window below I used the setting myaa([8 8]) in the Matlab command window which means that the supersampling enlarge the figure 8x and then downscale it to 1/8 to get the original h x w.
As one can see the window of the figure has no operation icons or menu options for save or print. My question is what to do with such a figure (beside making screenshots)? Can I somehow use export-fig to save such a figure or load it in an image array and if yes, how?
It is also possible to use the setting myaa([8 1]) which results in a very large figure window that is larger than my screen (and has the unpleasant attribute that it can not be moved). It would be even better if such a whole figure could be saved (not only the visible part).
You can use getframe to grab current figure information in pixels.
However, while I do not know how this affects you, notice that MATLAB versions above 2014b (included) have already anti-aliasing. The code you linked seem to be from 2008, I am not 100% sure if it has become obsolete now.

how to save figure of gui plot which will run on a computer that does not have matlab

I have made a Gui program that I compile to EXE application which lots csv file into graph data. I buit a save button but I do not know how save figure with different name each time cause (savefig anduisave both uses matlab program). I am posting my code below if anyoff you guys figure out how to save gui figue into image or anything that does require matlab to open. Last function is the callback function for save button.
function ma_Callback(hObject, eventdata, handles)
% i tried uisave but not possible to run computer without matlab cause mcr
% does not run uisave
% i tried copyopbj but since i did not put a name on my figure it did not
% work
%savefig
If you are trying to save a kind of image from your figure, then the best option which supports many aspects, is using print function.
I have already done this in a compiled app and it works perfect. Using print function you can set different file type(vector formats like *.svg are also supported), resolution(dpi), and so many others.
Although you can use print function directly on the figure, but I found that the best way (More Customization like removing or adding some objects and changing many options) is to follow this steps:
Create another figure with Visible='on' but a position that is out of screen with the same width and height of Main Figure.
normalized position = [-1, -1, ?, ?]. (Create this figure in start up and don't destroy it until your app exits, let call it Print Figure).
Copy your figure content (or the parts you are interested in) using copyobj to that figure (you may need to set Parent property of some key objects like panels to this new figure). They would look exactly as they look in the main figure, because they have the same properties. you can add or remove some objects in this step.
Change aspect ratio of "Print Figure" for a better output.
Print this figure with all options (file format, dpi, ...) you need. in my own GUI i allowed the user to change this settings with an input dialog.
In my app i used functions like winopen to show the output, and output directory to the user, when the print task was done. Print process takes some time, specially if dpi is huge, so it is also a good idea to inactivate buttons and show wait cursor.
Update:
a simple usage would be:
print(MainFigure, 'myFileName', '-dpng', '-r300')

How to prevent XY Graph from opening during simulation in Simulink

I have a Simulink simulation containing a XY Graph block. When I start a simulation, it automatically opens an XY Graph, but I do not want this. I just want to be able to double-click on it after a Simulation if I wish to see its content, as I am also doing with scopes. I know that in a scope's settings, there is the option
Open at simulation start
I guess that there should be a similar setting to my XY Graph but I cannot find where it is. How can I prevent it from opening during a simulation?
Unfortunately, this block is implemented by an s-function that creates the figure (without providing much option there). So, the best that you could do would be to add code into a block (or model) callback to set the figure to not visible. Below is an example of how to find the figure handle and set it to not visible. This kind of thing can be found in sfunxy.m
Example:
set(get_param('your/xygraph/path','UserData'), 'Visible', 'off');
You would then need to run the following command to view the data (or create a shortcut).
set(get_param('your/xygraph/path','UserData'), 'Visible', 'on');
Obviously, this is not ideal. :)

Save figures EPS from Matlab P file without display

My function calls code from other functions I did not write those but I know what they do. One of them is .p Matlab file with obfuscated content.
I am doing batch processing of a number of files. I want to write the figures directly to file without display. So I can go through them separately.
Any ideas on how to achieve this.
Thanks!
Script to save matlab figures to a specified directory
The above link works but I still want to avoid displaying the figures at all. Directly print to file. But the work around can simply close all open figures after that loop.
In your script, as soon as you create the figure, set its visibility to off.
For example:
figure(28732);
set(28732,'visible','off'); %Now the figure is not shown
You can now work with the figure, plot, save etc, without the visual clutter or system overhead of displaying it.
If you want ALL of your figures to start without visibility, you can set the default property, as follows:
set(0,'DefaultFigureVisible','off').
This will cause all generated figures to be generated without visibility. (Note, this will be very confusing is you forget that this property is set.)
You should still close the figure as soon as possible in the script, as a part of good memory management.

Matlab: linkaxes squeezes my graph

I have drown several graphs thanks to "subplot" function on MatLab and it works well.
Nevertheless, I want all my graphs to have the same Y-scale so that I can compare them.
I used the "linkaxes" function and my all my graphs have the same scale but the problem is that some of my figures are "beheaded", lacking their upper part, or one of my figures is completely squeezed.
I don't get what happened. Could you please help me to solve the problem or tell me about another function that would be more appropriate in my case?
Here's part of my code:
for i=1:1:9
m=n(i);
fichier=sprintf('%d.txt',m);
M=load(fichier);
z=length(M(:,1));
x=M(1:z,1);
y=M(1:z,2);
a(i)=subplot(2,4,i)
contour3=plot(x,y)
linkaxes(a,'y')
end
linkaxes creates a permanent link between the scales of several axes, so that you can subsequently perform zoom operations (perhaps interactively) on one, and have the other automatically update.
If you need that functionality, then linkaxes is the right command (although you could possibly also look at linkprops).
However if all you need is to ensure that the y-axis limits of your axes are the same, it will probably be easier (and you will have more control) if you set them directly. You can retrieve the y-axis limits using ylim(axis_handle) and set them using ylim(axis_handle, [lower, upper]), or alternatively with get(axis_handle,'YLim') and set(axis_handle,'YLim',[lower,upper]). You might also look at the YLimMode property of the axis, which determines whether the axis limits are directly set or automatically resized.