- Enclose with " for exact match e.g., "uitable report"
- Advanced on-site Matlab training - amazing value
- Viewing saved profiling results
- Transparent labels
- Setting class property types – take 2
- Smart listbox & editbox scrollbars
- Faster findjobj
- Adding a search box to figure toolbar
- Upcoming public Matlab presentations
- Secure SSL connection between Matlab and PostgreSQL
- Customizing contour plots part 2
- Munich Germany visit, 9-11 May 2016
- Better MEX error messages
- Simple GUI Tabs for Advanced Matlab Trading App
- Quirks with compiled Matlab DLLs
- Convolution performance
- I am hiring a Matlab programmer (Tel Aviv)
- Desktop (38)
- Figure window (41)
- Guest bloggers (53)
- GUI (135)
- Handle graphics (72)
- Hidden property (37)
- Icons (7)
- Java (152)
- Listeners (20)
- Memory (14)
- Mex (10)
- Presumed future risk (325)
- Public presentation (2)
- Semi-documented feature (7)
- Semi-documented function (32)
- Stock Matlab function (122)
- Toolbox (5)
- UI controls (44)
- Uncategorized (12)
- Undocumented feature (169)
- Undocumented function (32)
TagsActiveX Callbacks COM Compiler Desktop Donn Shull Editor Figure FindJObj GUI GUIDE Handle graphics HG2 Hidden property HTML Icons Internal component Java JavaFrame JIDE JMI Listener Malcolm Lidierth MCOS Memory Menubar Mex Optical illusion Performance Profiler Pure Matlab schema schema.class schema.prop scribe Semi-documented function Toolbar uicontrol UIInspect uitable uitools uiundo Undocumented feature Undocumented function Undocumented property
- Yair Altman (3 hours 49 minutes ago): @Stephan – again I reiterate: IB-Matlab does NOT contain any GUI. It is a pure Matlab function without any GUI. Perhaps you’re referring to some GUI program that is...
- Stephan Arendt (4 hours 3 minutes ago): @Yair I am talking about the GUI used in your tool (IB-Matlab: trade with InteractiveBrokers using Matlab). Sry i only used that missleading Abbreviation. And Yes I use the...
- Christoph Feenders (5 hours 32 minutes ago): addition: the problem only appears when using log-scaling on the y-axis and the y-data contains zeros. Minimal working example: h = scatter(1:5, [0 1 0 2 0]); set(gca(),...
- Christoph Feenders (5 hours 51 minutes ago): Hi, extracting the x-coordinates (on R2016a, Linux) using hLine.XData(logical(hLine.Brus hData)) works fine with data plotted using plot(), but if I use scatter()...
- Yair Altman (8 hours 1 minute ago): @Ivan – read my reply above. I am not a free public service.
- Ivan (22 hours 16 minutes ago): Thank you for the availability!! Now I have a new problem, Matlab gives me the error: ”The CLASS function must be called from a class constructor.” And after days of...
- Yair Altman (1 day 1 hour ago): @Stephan – thanks for the feedback about my Expo presentation, but I don’t understand your question: IB-Matlab is “just” a connector between...
- Stephan Arendt (1 day 7 hours ago): Hello Yair, I used your code to create Tabs and Childtabs. When I compared them to your IB-Matlab Gui i noticed that the Tabs look much better then the standard text fields?...
- Yair Altman (4 days 18 hours ago): @Loops – axes are not uicontrols and they have an entirely different set of properties, events and callbacks. Search this blog for specific axes keywords and maybe you...
- Ondrej (4 days 20 hours ago): I am struggling for a while with an efficient retrieving of dynamic changing substructures from a string. According to my measurements, classical for loop combined with regexp is the...
- Loops (5 days 2 hours ago): Hi Yair Are there any callback controls in axes? I want monitor “PropertyCahnged” event. Or, re-create a class for axes? Thanks
- Travis (5 days 23 hours ago): Yair, I am trying to set the position in a uitable, but I can’t for the life of me find how to change the ‘value’ field for the vertical scroll bar. Using your...
- Yair Altman (6 days 8 hours ago): It is best to create all Matlab GUI components on the EDT (using Matlab’s built-in javaObjectEDT function) and then add them to the GUI using the javacomponent function....
- Collin Pecora (6 days 15 hours ago): Sorry if I am off topic, don’t know how you would like new questions. I have a standard matlab function that returns a formatted javax.swing.JLabel, the JLabel is...
- Jay Willis (7 days 0 hours ago): Thanks. This fix (drawnow; pause(0.05)) still works for me, using R2015b
Many Matlab users know and utilize Matlab’s built-in Profiler tool to identify performance bottlenecks and code-coverage issues. Unfortunately, not many are aware of the Profiler’s programmatic interface. In past articles as well as my performance book I explained how we can use this programmatic interface to save profiling results and analyze it offline. In fact, I took this idea further and even created a utility (profile_history) that displays the function call timeline in a standalone Matlab GUI, something that is a sorely missed feature in the built-in profiler:
Function call timeline profiling (click for full-size image)
Today I will discuss a related undocumented feature of the Profiler: loading and viewing pre-saved profiling results.
For the application that I will be presenting at next week’s MATLAB Expo in Munich (presentation slides), I wanted to add a text label at a specific location within the figure. The problem was, as you can clearly see from the screenshot below, that there is precious little available space for a new label. I could drive the entire content down to make space for it, but that would reduce the usable space for the actual contents, which is already at a premium:
Adding a transparent label to Matlab GUI (click for full-size image)
A natural place for the new label, as indicated, would be on top of the empty space next to the content’s sub-tabs (Correlation and Backtesting). This empty space is taken up by Matlab’s uitabgroup control, and we can simply place our label on top of it.
Well, easier said than done…
Three years ago, almost to the day, I wrote about a very handy undocumented feature of Matlab classes that enables us to specify type restrictions for any Matlab class property. We can specify property type (for example,
double or any Matlab class) as well as dimensionality (
matrix) and complexity indication (
complex). Doing so has multiple benefits for code performance, robustness and maintainability. For example:
% Undocumented syntax - works well since at least R2010a (possibly earlier) classdef Packet properties PacketType@char HeaderLength@uint16 PayloadLength@uint16 scalar = uint16(0); % initial value PacketData@uint8 vector end end
In the recent release of Matlab R2016a, a similar feature have finally become fully supported and documented. The corresponding snippet above would look something like this:
% Documented syntax - only works in R2016a or newer classdef Packet properties PacketType char HeaderLength uint16 PayloadLength uint16 = uint16(0); % initial value PacketData uint8 end end
Unfortunately, I dislike the new documented functionality, so I didn’t feel like promoting it in this blog when it came out. But since a blog reader mentioned it a few days ago, I wanted to come out publicly with my opinion and a detailed explanation.
A good friend recently asked me for examples where using Java in Matlab programs provides a significant benefit that would offset the risk of using undocumented/unsupported functionality, which may possibly stop working in some future Matlab release. Today I will discuss a very easy Java-based hack that in my opinion improves the appearance of Matlab GUIs with minimal risk of a catastrophic failure in a future release.
The problem with Matlab listbox and multi-line editbox controls in the current (non web-based) GUI, is that they use a scrollbar whose behavior policy is set to
VERTICAL_SCROLLBAR_ALWAYS. This causes the vertical scrollbar to appear even when the listbox does not really require it. In many cases, when the listbox is too narrow, this also causes the automatic appearance of a horizontal scrollbar. The end result is a listbox that displays 2 useless scrollbars, that possibly hide some listbox contents, and are a sore to the eyes:
By default, Matlab implements a vertical scrollbar policy of
VERTICAL_SCROLLBAR_ALWAYS for sufficiently tall uicontrols (>20-25 pixels, which practically means always) and
VERTICAL_SCROLLBAR_NEVER for shorter uicontrols (this may possibly be platform-dependent).
A similar problem happens with the horizontal scrollbar: Matlab implements a horizontal scrollbar policy of
HORIZONTAL_SCROLLBAR_NEVER for all editboxes and also for narrow listboxes (<35 pixels), and
HORIZONTAL_SCROLLBAR_AS_NEEDED for wide listboxes.
My findjobj utility, created in 2007 and updated over the years, has received wide recognition and is employed by numerous Matlab programs, including a few dozen utilities in the Matlab File Exchange. I am quite proud of this utility and find it extremely useful for customizing Matlab controls in many ways that are impossible using standard Matlab properties. I have shown many examples of this in this blog over the past years.
I am happy to announce that I have just uploaded a new version of findjobj to the Matlab File Exchange, which significantly improves the utility’s performance for the most common use-case of a single input and a single output, namely finding the handle of the underlying Java component (peer) of a certain Matlab control:
>> hButton = uicontrol('String','click me!'); >> tic, jButton = findjobj(hButton); toc % old findjobj Elapsed time is 1.513217 seconds. >> tic, jButton = findjobj(hButton); toc % new findjobj Elapsed time is 0.029348 seconds.
The new findjobj is backward-compatible with the old findjobj and with all prior Matlab releases. It is a drop-in replacement that will significantly improve your program’s speed.
The new version relies on several techniques: Continue reading
Last week I wrote about my upcoming presentations in Tel Aviv and Munich, where I will discuss a Matlab-based financial application that uses some advanced GUI concepts. In today’s post I will review one of these concepts that could be useful in a wide range of Matlab applications – adding an interactive search box to the toolbar of Matlab figures.
The basic idea is simple: whenever the user types in the search box, a Matlab callback function checks the data for the search term. If one or more matches are found then the searchbox’s background remains white, otherwise it is colored yellow to highlight the term. When the user presses <Enter>, the search action is triggered to highlight the term in the data, and any subsequent press of <Enter> will highlight the next match (cycling back at the top as needed). Very simple and intuitive:
- April 5, 2016 – Tel Aviv, Israel – Matlab Data Analytics
- May 10, 2016 – Munich, Germany – Matlab Expo (see the presentation slides)
In both cases I will present a professional pairs-trading and analysis application developed for a New York hedge fund. This application analyzes large amounts of data relatively quickly, and presents the results in a professional-grade GUI. My aim is to use this example to show that contrary to a widespread mis-conception, professional Matlab programs can be created without sacrificing performance (speed) or appearance. Coupled with Matlab’s recognized benefits (rapid app development and off-the-shelf functionality), Matlab is certainly relevant for serious user-facing applications, not just for prototyping and internal organizational use.
My presentations will be focused on the technical Matlab aspects, not the specific financial functionality of the program. I am targeting the presentations at anyone who designs and creates Matlab programs, not just in the financial fields. I will discuss some of the technical challenges encountered during the development, and a few simple techniques that can be very effective for improving run-time performance and visualization quality.
If you are in the area and wish to meet me to discuss how I could bring value to your work, then please email me (altmany at gmail) to coordinate a meeting. We could meet either at the conferences, or in a dedicated (private) meeting.
I’d like to introduce guest blogger Jeff Mandel of the Perelman School of Medicine at the University of Pennsylvania. Today Jeff will discuss a how-to guide for setting up an SSL connection between Matlab and a PostgreSQL database. While this specific topic may be of interest to only a few readers, it involves hard-to-trace problems that are not well documented anywhere. The techniques discussed below may also be applicable, with necessary modifications, to other SSL targets and may thus be of use to a wider group of Matlab users.
I’m developing software for pharmacokinetic control, and needed secure access to a central database from users at remote sites. The client software is written in Matlab, and while I have targeted MacOS, this could be adapted to Windows fairly easily. Hopefully, this will save someone the week it took me to figure all this out.
- PostgreSQL 9.4 installed on the server (Windows 7 PC, but Linux would be equally good)
- DynDNS CNAME pointing at the server (diseserver.mydomain.org)
- CACert.org registration for domain mydomain.org
- Matlab 2015b running on El Capitan
Here are the neccesary steps:
A few months ago I discussed various undocumented manners by which we can customize Matlab contour plots. A short while ago I receive an email from a blog reader (thanks Frank!) alerting me to another interesting way by which we can customize such plots, using the contour handle’s hidden ContourZLevel property. In today’s post I will explain how we can use this property and expand the discussion with some visualization interactivity.
The ContourZLevel property
The contour handle’s ContourZLevel property is a hidden property. This means that, just like all other hidden properties, it is accessible if we just happen to know its name (which is easy using my getundoc utility). This property sets the Z level at which the contour lines are drawn.
For example, by default the meshc function sets ContourZLevel‘s value to the bottom of the 3D display (in other words, to the axes’ ZLim(1) value). This is done within the mesh.m function:
We can, however, modify the contour’s level value to any other Z location:
I will be visiting clients in Munich, Germany between 9-11 May 2016, for advanced Matlab training and consulting. During this visit I will also present at the annual MATLAB Expo on May 10: MathWorks were very kind to invite me to speak as one of the keynote addresses in the plenary session, and I will do my best not to disappoint them or the audience.
In the Expo, my presentation will discuss a professional pairs-trading and analysis application developed for a New York hedge fund. This application analyzes large amounts of data relatively quickly, and presents the results in a professional-grade GUI. My aim is to use this example to show that contrary to a widespread mis-conception, Matlab programs can be made professional-looking without sacrificing performance (speed), and that coupled with Matlab’s recognized benefits (rapid app development and off-the-shelf functionality) Matlab is certainly relevant for serious user-facing applications, not just for prototyping and internal organizational use. I will discuss some of the technical challenges encountered during the development, and show some simple techniques that can be very effective for improving run-time performance and visualization quality.
If you are in the München area between May 9-11 and wish to meet me to discuss how I could bring value to your work, then please email me (altmany at gmail). We could meet either at the Expo, or in a dedicated (private) meeting.