I am developing a complex program in MATLAB R2013a to evaluate EEG and other data recorded from animals. I have a main GUI with a menu bar and two panels on which up to 16-16 axes can be shown. I created two GUIs with GUIDE. One is used to set the sampling rate, the number of recorded channels, etc., when I open a new data file. The other GUI is used to set how many graphs should be drawn in the main GUI, which recorded channel should be shown, is filtering necessary or not, etc. To set all these things takes about 400 controls (popuplists, checkboxes, etc.)
I call these GUIs several times from the main GUI. The first GUI keeps all changes that I made during the previous call, while the other GUI is reset to the initial state whenever I call it. Of course, I could store the values of these 400 controls, and somehow restore them to the previous state, but it would be very tedious.
Can somebody tell me why the two GUIs behave differently? In my view, it is not unusual that a GUI is called more than once from a program, and it also seems natural that the user only wants to change a few settings and not rewrite everything.
Related
I am building an app with the App Designer. The figure includes multiple plots that are synced. I would like to make something to scroll through the plots so that I can show a set amount of time at any given time. As it is now, it includes the ability to pan and zoom with just mouse controls. I cannot find a way to make such a scroll bar.
I was thinking of using the slider tool to keep re-plotting the plot based on where the slider begins, but that solution is very messy. And it could lead to some data never appearing.
Even if I could just make some way for me to set the plot to just show a given x interval (say 100 units of time) and use a key press to go to the next x interval without skipping anything.
Any help would be greatly appreciated!
I would like to be able to add a figure container to a matlab gui...
In core matlab, with a docked window style you can have a large number of plots stacked one behind the other, all within a figure container with a tabbed list along the side of the container that you can simply click to bring a particular figure to the front.
Is there a way to have this sort of figure container in a matlab gui?
Use Ben Tordoff's GUI Layout Toolbox. It contains functionality for tabbed panels and dockable/undockable panels that can contain figures, and many other capabilities that you'll find very useful if you are creating GUIs in MATLAB.
You will need to organize your GUI code slightly differently, but it's not hard to learn and there are great examples in the documentation.
It's not really possible to do what you're describing with just regular MATLAB: figures will just dock into the main MATLAB desktop, not into your GUI specifically. The best way (without GUI Layout Toolbox) would probably be to fake a row of tabs using buttons next to each other, with callbacks on the buttons that deleted/hid one plot and drew/revealed another. There is a function uitab that does tabs, but before R2014b it's undocumented, and it's a bit of a pain anyway. Better all round to use GUI Layout Toolbox.
If you're open to play around with undocumented features, this can be done using the java objects behind the matlab figures, e.g. using a little tool from the fileexchange.
This will create a new dock group, just like MATLAB's container for figures, editor etc.
I have been searching for a long time and have yet to find a tutorial/answer so I am posting the question here. How can I render a continuous signal within Simulink as a bar graph? The bar graph should be behaving similarly as the native default scope block within Simulink. I.e.: the graph changes in real-time while the signal is running. The same functionality (or close to it) as scope, but in a bar graph format. Any help or directions are appreciated.
There is a Floating Bar Plot in the Simulink Extras->Additional Sinks library.
However, it has very limited functionality.
The best way to do this is to write an (m-code) S-Function. Although not difficult, it's not going to be trivial to do properly. Within the S-Function you'll need to do things like
initialize a figure window and an axes on it, and open the figure if it is still open (from a previous simulation).
update the plot (efficiently, and most likely using low level functions, not the bar function itself)
check that the user hasn't closed the figure, and only plot data if it hasn't (or reopen the figure if it has been closed).
You will most likely also need to use some of the block callbacks to do the right thing if the block is deleted (e.g. delete the figure too, if it's still open), copied, etc.
I have created a basic MATLAB UI (without using GUIDE). I basically have a bunch of panels for various things, (sliders, axes, text boxes, etc).
The one thing I would like to do though, it make it so that they scale properly, when I resize the figure. Right now, I painstakingly have to make a re-scale function for every button, panel, sub-panel, etc etc to make it rescale correctly.
Is there an easy way to simply automate the re-scaling here?
Thanks.
Use the GUI Layout Toolbox from the MATLAB File Exchange. I haven't personally used dynamic resizing functionality, but that's one benefit of using this package.
It functions much like using uicontrols, except you can't use the inspect tool on these objects.
EDIT: If you're looking only to do resizing when the figure itself is resized, set the Units property for all your uicontrols to normalized.
You could also use the builtin, but undocumented uigridcontainer and uiflowcontainer.
They have the benefit of e.g. allowing to set contraints, such that e.g. your pushbuttons don't get increased in size, when the full figure does. Check the link for some examples:
http://undocumentedmatlab.com/blog/matlab-layout-managers-uicontainer-and-relatives/
To see what I mean excatly please:
Run the code below
figure
plot(peaks)
cameratoolbar('SetMode','orbit');
cameratoolbar('Show');
Move mouse onto the plot. Hold down the left click, move the mouse to left ot right then release the click. You'll see the plot start sniping for ever.
Now if you click on the red, stop sign button it stops from spinning. However I would like to programmatically stop the spinning plot. Any thoughts?
Opening cameratoolbar in the editor reveals that orbiting is accomplished by setting the figure's WindowButton* callbacks temporarily to nested/sub functions within cameratoolbar.
Judging from the 1-minute diagonal read-through I did, the camera orbit itself is accomplished by calling a pan/zoom function orbitPangca, which recursively calls cameratoolbar. This recursion loop is controlled by flags which are toggled by the callbacks from the toolbar buttons. These flags alter the behaviour of each iteration in the recursion loop.
If this is indeed the case, it would imply that Matlab is not accepting commands from any source you have programmatic control over, while the plot is orbiting. It'll only respond to the button presses. This means that if you want to stop the motion programmatically, you'd have to hack cameratoolbar to allow for this - not the most portable option.
Another idea that just popped to mind, is figuring out which WindowButton* callback is used for the orbit, and define your own function there. You might just be lucky enough that the MathWorks implemented cameratoolbar such that both callbacks are called each iteration, which would give you programatic control over the flags. But -- you'd have to test this yourself.