Converting Matlab GUI into a guide GUI - matlab

I have inherited a pile of Matlab scripts that manually build a GUI using calls to uicontrol, uimenu, etc. Over the years we have needed to remove and add elements to the GUI and since all the positions are specified manually in the scripts, the layout hasn't really changed to accommodate the missing elements so it is really starting to look like a pile of trash.
Is there a way to automatically convert my matlab scripted gui into something I can use with guide? I would rather not have to start over...

GUIs generated with GUIDE are not much better than manually scripted ones (if not worse in my opinion in terms of maintainability).
The sad truth is that there are no builtin layout managers in MATLAB (there are user-contributed ones on FEX like border layout, gridbag layout and others). If you are refactoring the code, please consider using some sort of GUI layout manager.
To answer your question, afaik there is no automatic tool for such a conversion.
To be exact, MATLAB has some undocumented layout managers: uiflowcontainer and uigridcontainer. See this article by Yair Altman

Well, there is no automatic conversion utility but you dont need to create everything from scratch with GUIDE.
Execute your GUI so that it shows up and save the figure window as a fig file. This file then can be edited with guide.
However this needs manual adjustments in your code. Especially if you need access to handles and I am also not sure about the callback functions.
However, as Amro already pointed out, GUIDE is not a perfect solution.

Related

Change focus in MATLAB App Designer

I'm looking for a method to programmatically change the focus to a different panel in the MATLAB App Designer. I have a push-button that I would like to use to shortcut the user to a specific panel in the same UI. My UI is arranged using a series of tab-panels, and I need a way to directly send the user to a different panel.
For normal (non App Designer) MATLAB UI components, I can use the command uicontrol(itemOfInterest); to give focus to a particular element of the UI, but this isn't possible with App Designer. Is there a specific command?
It seems that, for what concerns the App Designer, as of Matlab R2017a, this feature has not been implemented yet. Googling a little bit, I found this question, in which the OP basically asks the same. The provided (and accepted) answer is:
This functionality with "uicontrol" is currently unavailable in App
Designer. I have forwarded your feedback to our developers and they
will consider adding support for this in a future release of MATLAB.
With a little bit of patience, the focus support will be introduced in a new Matlab release. Meanwhile, I suggest you to do some research focusing on undocumented Matlab features and underlying Java components. With a little bit of luck and findjobj you could be able to achieve what you are looking for.

transparent background in figure (matlab)

I'd like to save a matlab figure with transparent background, on mac, and import into Keynote.
This question was asked in 2013, but I understand matlab has changed its graphics handling since then. Is there a 'good' way to do this? The plotting syntax is so scattered and overloaded.
I looked for this myself some time ago. Mathworks seems to state that this is not directly possible in matlab and that it isn't a feature they plan on introducing as well:
http://ch.mathworks.com/matlabcentral/answers/19907-transparent-background-for-figures
But as stated in the link it can easily be achieved using a third-party program (for example inkscape, which is freeware(opensource?) program) if you export the figure as a .eps or .pdf. This basically enables you to directly edit or delete certain parts of the image.
This is probably not exactly what you were looking for, but I know of no easier native solution than this. However the author refers to export_fig which might directly solve you porblem (I don't have any experience using it, sorry).

How to implement fixed point operations without Fixed Point Designer Library in Matlab?

I am supposed to work with an existing code in my work and at some places the previous programmer has extensively used Fimath function. Unfortunately, I am not having the license for the Fixed Point Designer toolbox and was looking for some alternatives.
I tried getting the fimath.m file from another source but it is referencing to some embedded libraries in the toolbox.
Is there some other way in which I can bypass this problem?
Thank You

Matlab Vs. Maple for curve fitting to data, finding eq'n of curve then integrating through code

Im sure there are a thousand different posts on Maple vs Matlab, but i have a bit of a unique set of requirements and before i go off to learn one of the two i would like to know which one will do it best.
I have a set of data from an accelerometer recording an impact. I need to do the following:
fit a curve to the data
Find the equation for that curve
solve the equation listed at the link
http://upload.wikimedia.org/wikipedia/en/math/2/d/3/2d39556df1dbbd467dc914253e93cdb0.png
which solves for a family of curves,i.e the MAX under the interval.
I would like to do this as seamlessly with visual studio as possible. The GUI and all the other elements of the app are built in VB and I would like to keep it there. I know maple has a code generating part to it that will convert to VB, would it be able to handle something like this? Does Matlab integrate with Visual Studio well? I would be thrilled if there was an object i could place on the VB form which would facilitate the communication to and from the matlab or maple framework. Currently i have it working with R, however to do so i need to write the data to a file, launch the R script, wait for it to finish, return control to my VB app and take it from there. This process takes too long and since i do not have experience with multi threaded programming the GUI freezes up when control is passed to the script.
Any help or suggestions would be very much appreciated!
In your case I would choose neither of the two. You may have a look at Python Tools for Visual Studio. The blog post mentions support for NumPy & SciPy for .Net which gives you all the math power you need at hand well integrated in the .Net world.
EDIT:
By looking at matplotlib's gallery I'm tempted to say that matplotlib is on par with MATLAB.
MATLAB doesn't auto-generate VB code, but it can easily be called from a VB application without the indirection of writing a file. It has COM interface that can be called directly from within VB code. See this example from the MATLAB documentation to find out more.
To carry out the technical analysis you've mentioned, you would probably save time by using Curve Fitting Toolbox in addition to base MATLAB.
Note that the above method of connecting to MATLAB via its COM interface relies on there being a live copy of MATLAB present when the VB application is executed. If you need to share your application with people who don't have a copy of MATLAB, you can also create standalone COM components and .NET assemblies from MATLAB code that can be called in the same way by your VB code, but can be deployed freely to people without a MATLAB license - however, this requires an extra product, MATLAB Builder for .NET.

Graphically laying out wx app

Being really new to wx, I'm wondering if there is an IDE (especially for Linux) which would help me lay out a frame or dialog or whatever just to help me see what I'm doing. That means also creating the code for those changes.
I remember way back when using resource compilers for OS/2 and Windows that produced binaries that would then create the window, and was hoping for something similar (though obviously not binary if wx doesn't support that).
I use wxFormBuilder. It is written in wxWidgets, so it works on Linux quite well. It can generate C++ code or XRC files. Make sure you understand its philosophy, and use it like this:
generate C++ code for the GUI
don't edit the code wxFormBuilder generated, but create new files
in new files, derive new classes from the classes it generated
implement event handlers in you own class (wxFB creates virtual function for each event handler you wish to use)
I usually name the wxFormBuilder generated classes/files like, for example, MainFrameGUI, and one with implementation (derived one in which I write all my code) would be just MainFrame. This enables you to change the visual layout and regenerate C++ files from wxFB at any time without overwriting your code.
DialogBlocks works quite well for me, although sometimes you need to edit the code to fix errors manually. It has a property editor that seems advanced enough.
Just another options is wxGlade. It does not have the that much features as the others mentioned seem to have, but it works just good enough for me to not daring to switch.
I use Code::Blocks IDE from http://www.codeblocks.org which has
- built-in GUI editor
- Cross compilable, so you can use it under Linux, OSX and Windows.
But I still use wxFormBuilder with it instead of built-in wxSmith editor. But they are compatible with internal wxSmith.
For windows you've got "wx-devcpp" which is Blodsheed Dev C++ with some addons providing what you looking for
Here is project page
http://wxdsgn.sourceforge.net/