Speeding-up builtin Matlab functions – part 3
Undocumented Matlab
by Yair Altman
3y ago
A recurring theme in this website is that despite a common misperception, builtin Matlab functions are typically coded for maximal accuracy and correctness, but not necessarily best run-time performance. Despite this, we can often identify and fix the hotspots in these functions and use a modified faster variant in our code. I have shown multiple examples for this in various posts (example1, example2, many others). Today I will show another example, this time speeding up the mvksdensity (multi-variate kernel probability density estimate) function, part of the Statistics toolbox since R2016a. Y ..read more
Visit website
Improving graphics interactivity
Undocumented Matlab
by Yair Altman
3y ago
Matlab release R2018b added the concept of axes-specific toolbars and default axes mouse interactivity. Plain 2D plot axes have the following default interactions enabled by default: PanInteraction, ZoomInteraction, DataTipInteraction and RulerPanInteraction. Unfortunately, I find that while the default interactions set is much more useful than the non-interactive default axes behavior in R2018a and earlier, it could still be improved in two important ways: Performance – Matlab’s builtin Interaction objects are very inefficient. In cases of multiple overlapping axes (which is very common in ..read more
Visit website
Interesting Matlab puzzle – analysis
Undocumented Matlab
by Yair Altman
3y ago
Last week I presented a seemingly-innocent Matlab code snippet with several variants, and asked readers to speculate what its outcomes are, and why. Several readers were apparently surprised by the results. In today’s post, I offer my analysis of the puzzle. The original code snippet was this: function test try if (false) or (true) disp('Yaba'); else disp('Daba'); end catch disp('Doo!'); end end With the following variants for the highlighted line #3: if (false) or (true) % variant #1 (original) if (true ..read more
Visit website
Interesting Matlab puzzle
Undocumented Matlab
by Yair Altman
3y ago
Here’s a nice little puzzle that came to me from long-time Matlab veteran Andrew Janke: Without actually running the following code in Matlab, what do you expect its output to be? ‘Yaba’? ‘Daba’? perhaps ‘Doo!’? or maybe it won’t run at all because of a parsing error? function test try if (false) or (true) disp('Yaba'); else disp('Daba'); end catch disp('Doo!'); end end To muddy the waters a bit, do you think that short-circuit evaluation is at work here? or perhaps eager evaluation? or perhaps neither? Would the results be ..read more
Visit website
Undocumented plot marker types
Undocumented Matlab
by Yair Altman
3y ago
I wanted to take a break from my miniseries on the Matlab toolstrip to describe a nice little undocumented aspect of plot line markers. Plot line marker types have remained essentially unchanged in user-facing functionality for the past two+ decades, allowing the well-known marker types (.,+,o,^ etc.). Internally, lots of things changed in the graphics engine, particularly in the transition to HG2 in R2014b and the implementation of markers using OpenGL primitives. I suspect that during the massive amount of development work that was done at that time, important functionality improvements that ..read more
Visit website
Matlab toolstrip – part 9 (popup figures)
Undocumented Matlab
by Yair Altman
3y ago
In previous posts I showed how we can create custom Matlab app toolstrips using various controls. Today I will show how we can incorporate popup forms composed of Matlab figures into our Matlab toolstrip. These are similar in concept to drop-down and gallery selectors, in the sense that when we click the toolstrip button a custom popup is displayed. In the case of a popup form, this is a fully-customizable Matlab GUI figure. Toolstrips can be a bit complex to develop so I’m proceeding slowly, with each post in the miniseries building on the previous posts. I encourage you to review the earlie ..read more
Visit website
Matlab toolstrip – part 8 (galleries)
Undocumented Matlab
by Yair Altman
3y ago
In previous posts I showed how we can create custom Matlab app toolstrips using various controls (buttons, checkboxes, drop-downs, lists etc.). Today I will show how we can incorporate gallery panels into our Matlab toolstrip. Toolstrips can be a bit complex to develop so I’m proceeding slowly, with each post in the miniseries building on the previous posts. I encourage you to review the earlier posts in the Toolstrip miniseries before reading this post. Also, remember to add the following code snippet at the beginning of your code so that the relevant toolstrip classes will be recognized by ..read more
Visit website
Matlab toolstrip – part 7 (selection controls)
Undocumented Matlab
by Yair Altman
3y ago
In previous posts I showed how we can create custom Matlab app toolstrips using controls such as buttons, checkboxes, sliders and spinners. Today I will show how we can incorporate even more complex selection controls into our toolstrip: lists, drop-downs, popups etc. Toolstrip SplitButton with dynamic popup and static sub-menu Toolstrips can be a bit complex to develop so I’m proceeding slowly, with each post in the miniseries building on the previous posts. I encourage you to review the earlier posts in the Toolstrip miniseries before reading this post. Also, remember to add the following c ..read more
Visit website
Matlab toolstrip – part 6 (complex controls)
Undocumented Matlab
by Yair Altman
3y ago
In previous posts I showed how we can create custom Matlab app toolstrips using simple controls such as buttons and checkboxes. Today I will show how we can incorporate more complex controls into our toolstrip: button groups, edit-boxes, spinners, sliders etc. Toolstrips can be a bit complex to develop so I’m proceeding slowly, with each post in the miniseries building on the previous posts. I encourage you to review the earlier posts in the Toolstrip miniseries before reading this post. The first place to search for potential toostrip components/controls is in Matlab’s built-in toolstrip de ..read more
Visit website
Matlab toolstrip – part 5 (icons)
Undocumented Matlab
by Yair Altman
3y ago
In a previous post I showed how we can create custom Matlab app toolstrips. Toolstrips can be a bit complex to develop so I’m trying to proceed slowly, with each post in the miniseries building on the previous posts. I encourage you to review the earlier posts in the Toolstrip miniseries before reading this post. Today’s post describes how we can set various icons, based on the toolstrip created in the previous posts: Toolstrip example (basic controls) Component icons Many toolstrip controls (such as buttons, but not checkboxes for example) have a settable Icon property. The standard practice ..read more
Visit website

Follow Undocumented Matlab on FeedSpot

Continue with Google
Continue with Apple
OR