- Enclose with " for exact match e.g., "uitable report"
- Advanced on-site Matlab training, amazing value - additional info
- Undocumented HG2 graphics events
- copyobj behavior change in HG2
- General-use object copy
- Auto-completion widget
- Undocumented view transformation matrix
- Handle object as default class property value
- Plot legend title
- Using Infiniband with Matlab Parallel Computing Toolbox
- Frameless (undecorated) figure windows
- Transparent legend
- Customizing Matlab uipanels
- Simulink Data Dictionary
- Accessing hidden HG2 plot functionality
- Matlab compiler bug and workaround
- Desktop (35)
- Figure window (36)
- Guest bloggers (47)
- GUI (120)
- Handle graphics (65)
- Hidden property (34)
- Icons (7)
- Java (139)
- Listeners (18)
- Memory (14)
- Mex (9)
- Presumed future risk (292)
- Semi-documented feature (7)
- Semi-documented function (31)
- Stock Matlab function (114)
- Toolbox (4)
- UI controls (41)
- Uncategorized (10)
- Undocumented feature (146)
- Undocumented function (30)
TagsActiveX Callbacks COM Compiler Desktop Donn Shull Editor FindJObj GUI GUIDE Handle graphics HG2 Hidden property HTML Icons Internal component Java JavaFrame JIDE JMI keyboard 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
- Noam Greenboim (3 hours 6 minutes ago): Thanks for posting this, I have the same issue every now and then.
- Yair Altman (3 days 1 hour ago): @Christian – apparently you are not accessing the tab-group handle but a plain graphics surface handle. Follow the instructions in my blog to get the correct Java tabgroup...
- Christian T (5 days 1 hour ago): Hello Yair, when i’m trying to use your example for uitab close buttons, i always get the Error Message: No appropriate method, property, or field setTabComponentAt for...
- Richard de Garis (6 days 3 hours ago): Hi Yair, What is the issue (#21) with bold TeX axes labels / titles, in 2014b? I’m using 2014b, and I commented out the section that sets the FontWeight of texLabels to...
- Yair Altman (7 days 3 hours ago): Not directly, but you could try using the low-level HDF5 functions for this.
- CaptainObv (7 days 3 hours ago): Is it possible to save matfiles without creating the initial variable at the beginning? I am continually adding output data to my matfile block by block (I.e continually...
- Yair Altman (10 days 10 hours ago): MathWorks removed the UserData property (and some other generic properties such as ApplicationData) from Java components a few releases ago. In general, code that relies on...
- Amir (10 days 10 hours ago): Hello Yair, First your blog is really useful and helpful. I’m working on a GUI that contain a uitree, now I wanted to export that uitree to enable user to save it to an external...
- Ujjawal (12 days 6 hours ago): Hi, Nice post. Is there a way to press right control(Ctrl) key on windows using Robot or if there is some other solution to press right control key programatically? Best Regards
- Stephanie (12 days 23 hours ago): Hi Yair, Assigning the renderer object to all the table columns as follows: for j = 1 : length(cnames3) jTable.getColumnModel.getColum n(j-1).setCellRenderer(cr); end is making my...
- Stephanie (13 days 2 hours ago): You probably figured it out by now, but for future readers: I got this error when trying to display different uitables at the same position.
- Stephanie (13 days 2 hours ago): Hi Yair, Thank you, it’s working perfectly.
- Yair Altman (14 days 0 hours ago): You can use DefaultTableModel with dummy column headers (identifiers), and then remove the table header: jTable.setTableHeader();
- Stephanie (14 days 4 hours ago): Hi Yair, Thank you for posting this. Is there a way to replace Matlab’s table model with something more renderer-friendly without headers? My headers are included in the...
- Yair Altman (15 days 7 hours ago): cute
R2014b brought a refreshing new graphics engine and appearance, internally called HG2 (the official marketing name is long and impossible to remember, and certainly not as catchy). I’ve already posted a series of articles about HG2. Today I wish to discuss an undocumented aspect of HG2 that I’ve encountered several times over the past months, and most recently today. The problem is that while in the previous HG1 system (R2014a and earlier) we could add property-change listener callbacks to practically any graphics object, this is no longer true for HG2. Multiple graphics properties, that are calculated on-the-fly based on other property values, cannot be listened-to, and so we cannot attach callbacks that trigger when their values change.
Property-change listeners in HG1
Take for example my post about setting axes tick labels format from 3 years ago: the idea there was to attach a Matlab callback function to the
PropertyPostSet event of the XTick, YTick and/or ZTick properties, so that when they change their values (upon zoom/pan/resize), the corresponding tick-labels would be reformatted based on the user-specified format:
As a followup to last-week’s post on class-object and generic data copies, I would like to welcome back guest blogger Robert Cumming, who developed a commercial Matlab GUI framework. Today, Robert will highlight a behavior change of Matlab’s copyobj function in HG2.
One of the latest features that was introduced to the GUI Toolbox was the ability to undock or copy panels, that would be displayed in a standalone figure window, but remain connected to the underlying class object:
These panel copies had to remain fully functional, including all children and callbacks, and they needed to retain all connections back to the source data. In the example above I have altered the plot to show that it’s an actual copy of the data, but has separate behavior from the original panel.
To simply undock a uipanel to a new figure, we can simply re parent it by updating its Parent property to the new figure handle. To make a copy we need to utilize the copyobj function, rather than re-parenting. copyobj can be used to make a copy of all graphic objects that are “grouped” under a common parent, placing their copy in a new parent. In HG2 (R2014b onwards) the default operation of copyobj has changed.
When using Matlab objects, either a Matlab class (MCOS) or any other (e.g., Java, COM, C# etc.), it is often useful to create a copy of the original object, complete with all internal property values. This enables modification of the new copy without affecting the original object. This is not important for MCOS value-class objects, since value objects use the COW (Copy-on-Write/Update, a.k.a. Lazy Copy) and this is handled automatically by the Matlab interpreter when it detects that a change is made to the copy reference. However, it is very important for handle objects, where modifying any property of the copied object also modifies the original object.
Most OOP languages include some sort of a copy constructor, which enables programmers to duplicate a handle/reference object, internal properties included, such that it becomes entirely separate from the original object. Unfortunately, Matlab did not include such a copy constructor until R2011a (matlab.mixin.Copyable.copy()).
On Matlab R2010b and older, as well as on newer releases, we do not have a readily-available solution for handle object copy. Until now, that is.
Do you ever get a feeling when designing a Matlab GUI, that existing components/controls are simply not enough to achieve the desired functionality/appearance?
Such a case happened to me, when a consulting client asked me to integrate an auto-completion widget in a GUI that I designed for them. The idea was simple enough: the user selects a class of financial assets from a drop-down, then one or more actual financial securities from a dynamically-populated drop-down (based on the asset class), then the date range and analysis function, and finally the results are plotted in the main panel. The idea was for Matlab to automatically auto-complete the financial instruments matching the entered text, as it is being typed, similarly to other standard auto-completion widgets (e.g., Google’s search box), including the use of wildcards and regular expressions:
Note that in this particular case, I use the term “auto-completion” loosely. The correct term should actually be “auto-winnowing” or “auto-filtering”. Auto-completion is usually reserved for the case of the user-entered text being automatically completed as they type, whereas auto-winnowing only updates the drop-down options on-the-fly. These two functionalities are often correlated, and today’s article will discuss both.
Everyone knows Matlab’s view function, right? You know, the function that can set a 3D plot to the proper orientation angles and/or return the current plot’s azimuth/elevation angles. I’ve used it numerous times myself in the past two decades. It’s one of Matlab’s earliest functions, dating back to at least 1984. Still, as often as I’ve used it, it was not until I came across Bruce Elliott’s post on CSSM last week that I realized that this seamingly-innocent stock Matlab function holds a few interesting secrets.
view()’s transformation matrix output
First, while view‘s 2-output syntax (
[az,el]=view()) is well known and documented, there is also a single-output syntax (
T=view()) that is neither. To be exact, this syntax is not mentioned in the official documentation pages, but it does appear in the help section of view.m, which is viewable (no pun intended…) if you type the following in your Matlab console (R2014a or earlier, note the highlighted lines):
We all know the benefits of setting default class-property values: it saves coding, increases class readability, improves maintainability and reduces the potential for coding bugs due to uninitialized properties. Basically, we’re setting default values of the class properties, so that whenever a new instance of this class is created, it will be recreated with these same default property values. This is the behavior in any self-respecting OOP language, and is a well-entrenched paradigm in OOP computing. Simple enough, right?
Well, unfortunately it doesn’t behave quite this way in Matlab…
This blog post was supposed to be a piece of cake: The problem description was that we wish to display a text title next to the legend box in plot axes. Sounds simple enough. After all, in HG1 (R2014a and earlier), a legend was a simple wrapper around a standard Matlab axes. Therefore, we can simply access the legend axes’s title handle, and modify its properties. This works very well in HG1:
hold all; hLine1 = plot(1:5); hLine2 = plot(2:6); hLegend = legend([hLine1,hLine2], 'Location','NorthWest'); hTitle = get(hLegend,'title'); set(hTitle, 'String','Plot types:', 'VerticalAlignment','middle', 'FontSize',8);
How hard then could a corresponding solution be in HG2 (R2014b+), right?
Well, it turns out that hard enough (at least for me)…
Carlos David Peña liked this post
I would like to welcome guest blogger Brock Palen, who is the Associate Director for Advanced Research Computing at the University of Michigan. Brock worked in High Performance computing since 2004 and is also one half of the Research Computing podcast; Research Computing and Engineering. You can find him blogging at failureasaservice.com. This is an updated repost of Brock’s article on UMich’s Flux HPC blog. Additional information on the Parallel Computing Toolbox can be found in my book Accelerating MATLAB Performance.
In High Performance Computing (HPC) there are a number of network types commonly used, among these are: Ethernet, the common network found on all computer equipment. Infiniband, a specialty high performance low latency interconnect common on commodity clusters. There are also several propriety types and a few other less common types but I will focus on Ethernet and Infiniband.
Ethernet and really its mate protocol, TCP, are the most common supported MPI networks. Almost all computer platforms support this network type and can be as simple as using your home network switch. It is ubiquitous and easy to support. Networks like Infiniband though require special drivers, uncommon hardware but the effort is normally worth it.
The MATLAB Parallel Computing Toolbox provides a collection of functions that allow MATLAB users to utilize multiple compute nodes to work on larger problems. Many may not realize that MathWorks chose to use the standard MPI routines to implement this toolbox. MathWorks also chose, for ease of use, to ship MATLAB with the MPICH2 MPI library, and the version they use only supports Ethernet for communication between nodes.
Unfortunately, Ethernet is about the slowest common network used in parallel applications. The question is how much can this impact performance.
All Matlab figures have a standard frame around them, consisting of a border and title bar. In some cases it could be useful to present a figure window, displaying only the contents without the border and title bar. Such a borderless (undecorated) window is not possible in Matlab. Well, at least not in supported/documented Matlab…
Readers of this blog and/or my Matlab-Java programming book are aware that Matlab’s GUI is based on Java Swing. In the end, every Matlab figure window is a simple Java
JFrame, and JFrames have a setUndecorated(true) method that can be called to remove the border and title bar.
An undecorated Matlab figure window
Carlos David Peña liked this post
I’ve been working lately on Matlab program for a client, which attempts to mimic the appearance and behavior of MetaTrader charts, which are extensively used by traders to visualize financial timeseries and analysis indicators.
Such charts are often heavily laden with information, and a legend can be handy to understand the meaning of the various plot lines. Unfortunately, in such heavily-laden charts the legend box typically overlaps the data. We can of course move the legend box around (programmatically or by interactive dragging). But in such cases it might be more useful to have the legend background become semi- or fully-transparent, such that the underlying plot lines would appear beneath the legend:
Matlab chart with a semi-transparent legend (click for details)