Comments for Undocumented Matlab Charting Matlab's unsupported hidden underbelly Tue, 24 Apr 2018 11:26:06 +0000 hourly 1 Comment on Customizing Workspace context-menu by MatthieuC Tue, 24 Apr 2018 11:26:06 +0000 To give more detail about my question… I would add some Subversion specific actions on Right-Click (for instance, setting working copy depth commands).
Thank you for your help.

Comment on Uitable cell colors by torsion27 Mon, 23 Apr 2018 17:19:36 +0000 is there a matlab gui way to set the row color? i am trying to get the row green if checkbox is checked and red if not, and can’t find a way right now. Tanks for help

% --- Executes when entered data in editable cell(s) in uitable3.
function uitable3_CellEditCallback(hObject, eventdata, handles)
spalte1=tabledata(:,1) %spalte 1 ist die ersrte spalte mit den checkboxen
% uitablehandles=findobj(handles.uitable3);
for j = 1:1:zeilenanzahl %für zeile 1 bis ende
   if (spalte1{j,1}==1)   
      set(handles.uitable3,'BackgroundColor',[0 1 0]) 
   for j = 1:1:zeilenanzahl  
      if (tabledata{j,1}==0) 
         tabledata{j,2}= set(handles.uitable3,'BackgroundColor',[1 0 0])
% --- Executes during object creation, after setting all properties.
function uitable3_CreateFcn(hObject, eventdata, handles)
hObject.ColumnFormat = {'logical',[]};  
hObject.ColumnEditable = logical([1 0]);
Comment on Customizing Workspace context-menu by MatthieuC Mon, 23 Apr 2018 12:06:44 +0000 Hello !
Is there an equivalent for the “Current Folder” context-menu?
I know the package is com.mathworks.mlwidgets.explorer but I cannot handle the way of adding context-menu with it.


Comment on AppDesigner’s mlapp file format by Tom Tue, 17 Apr 2018 13:43:15 +0000 Thanks for this tutorial. You saved me a ton of work. After Matlab crashed and corrupted my .mlapp file, I was able to unzip the .mlapp file and get to my GUI code and recreate my GUI. Without this, I would be months behind recreating the GUI and rewriting all the code. This website was a lifesaver. Thank you very much.

Comment on Uitab colors, icons and images by Yair Altman Thu, 05 Apr 2018 15:05:48 +0000 @Eric – HTML alignments only work within the area that the control allocates for the contents. It so happens that Java Swing allocates a tightly-fitting area for controls, so we basically have 3 options:

  • Use a fixed-width font and right-pad with spaces
  • Get the underlying Java handle of the tab-group and modify the Java properties (this became very difficult in recent Matlab releases)
  • Enlarge the allocated area dynamically via pure Matlab and HTML: We first get the width of the tabs, then we set the tab’s title to be a left-aligned table having the same fixed width as the tab (minus a bit due to the margins):
    pos = getpixelposition(tab1);
    tab1.Title = sprintf('<html><table align=left width=%d>Tab #1', pos(1)-4);
Comment on Solving an mput (FTP) hang problem by Mogh Thu, 05 Apr 2018 06:44:33 +0000 My same problem with “mput” function is solved.
thanks a lot for your useful suggestion.

Comment on Uitab colors, icons and images by Eric Wed, 04 Apr 2018 17:11:40 +0000 Yair,
I have a tab group positioned on the left using TabLocation and i am ok with the auto-sizing of the tabs to fit the longest tab name, but for all the tab names i would like them left justified. Trying to do this by setting the title property of the tab using an HTML string doesn’t seem to work. Is there a work around for this? Example code below:

hTabGroup2 = uitabgroup;
tab1 = uitab(hTabGroup2,'title','Tab #1');
tab2 = uitab(hTabGroup2,'title','This is a very long tab');
tab3 = uitab(hTabGroup2,'title','Tab #3');
set(tab1,'Title','Tab #1')
Comment on Waterloo graphics beta by Nino Mon, 02 Apr 2018 14:34:45 +0000 Hi Yair,

First of all, thank you very much for this great website. So far, together with your 2 books (which I recommend to buy and read), it represents the best resource available about Matlab programming and software development.

I have been trying to use the Waterloo graphics on a Mac with Matlab 2015b, and I have got the following error when running the PlotGallery() test function or one of the available plot examples, either in this blog or in the Waterloo project website:

Error using GXGraph (line 39)
Java exception occurred:
java.lang.NoSuchMethodError: org.jdesktop.swingx.painter.AbstractPainter.setAntialiasing(Z)V
	at org.jdesktop.swingx.JXLabel.initPainterSupport(
	at org.jdesktop.swingx.JXLabel.(
Error in GXFigure/subplot (line 112)
Error in gxgca (line 17)
        h=subplot(currentFigure, 1, 1, 1);

I have tried to install Waterloo in both ways, manually and by using the provided script, but I keep getting the same error. In I have also noticed that someone else had the same issue in the past, and after doing what Malcolm suggested in the discussion forum, the error is still there in my case.

I haven’t tried to install and use Waterloo on a Windows platform yet.

Any idea on what could cause that error and how I can fix it?

Thanks a lot,


Comment on Serializing/deserializing Matlab data by Yair Altman Mon, 02 Apr 2018 10:15:28 +0000 @Roc – thanks for the follow-up for the benefit of other readers

Comment on Serializing/deserializing Matlab data by Roc Woods Mon, 02 Apr 2018 10:08:08 +0000 I solved the problem. The problem is that when you compile to DLL, if you use the following command

mcc -W cpplib:testDeserialized -T link:lib testDeserialized.m -C;

the compiler can’t accurately package all the functions that need to be dependent on all the deserialization. At this time, create an empty object that needs to be deserialized, save it, such as nullObj.mat and then pack it with the -a option, and the compiler will analyze the mat file and automatically find the fully dependent functions. As shown below

mcc -W cpplib:testDeserialized -T link:lib testDeserialized.m -a nullObj.mat -C.

Thanks again @Yair

Comment on IP address input control by Lokesh Sharma Fri, 30 Mar 2018 10:16:12 +0000 this is a good method…

Comment on Waiting for asynchronous events by Yair Altman Fri, 30 Mar 2018 09:19:54 +0000 Unfortunately, using the Python object requires a separate installation of Python. While it is true that many users already have Python installed, many others do not and for such users the Python solution will error. In contrast, the solution that I presented above is based on the built-in waitfor function, and therefore works for all users.

Comment on Waiting for asynchronous events by Yair Altman Fri, 30 Mar 2018 09:15:54 +0000 I discussed Ctrl-C interrupts here:

Comment on Undocumented classdef attributes by Sam Roberts Wed, 28 Mar 2018 15:59:32 +0000 Maarten,

No, you can’t do that, although MathWorks are considering the possibility for a future enhancement. A similar question was asked on StackOverflow a while ago ( and received a couple of answers, one of which was from Andy Campbell, a senior developer at MathWorks. See the comment thread under his answer.

In the meantime, it is sometimes possible to achieve your aims by abusing the undocumented attributes Description and DetailedDescription.
These are undocumented, but are always present (on class, method, property and event elements), and accept a string value that you can use to store essentially whatever you want. Some built-in classes such as containers.Map use them to store a description of the class.

Because they are undocumented, if you use them they will cause a red underline in the MATLAB editor (without any actual runtime error). You can suppress this using %#ok<ATUNK> at the end of the line.

Comment on Serializing/deserializing Matlab data by Roc Woods Wed, 28 Mar 2018 15:46:40 +0000 @Yair, Thank you very much. I tried your suggestion, but it still has the same result as previous. It is noteworthy that the following code works fine in MATLAB:

function testDeserialized(matfilename)
   fileData = load(matfilename);
   netByte2 = uint8(fileData.netByteSaved);  % convert back to uint8
   net2 = getArrayFromByteStream(netByte2);
   save D:\net00.mat net2

but when I use the following code

mcc -W cpplib:testDeserialized -T link:lib testDeserialized.m  -C;

generate deployed files, such as testDeserialized.dll, testDeserialized.lib, testDeserialized.ctf and call testDeserialized.dll from C++ it has error when I tried to load D:\net00.mat. The error message is as follows:

Error using load
Cannot read file D:\net00.mat. 
try open('load(''D:\net00.mat'')Error: Character vector is not terminated properly.

when double click net00.mat,the error message changed to be

Warning: Unable to read some of the variables due to unknown MAT-file error.
> In matfinfo (line 9)
  In finfo (line 118)
  In internal.matlab.importtool.ImportableFileIdentifier.isTextFile (line 113)
  In internal.matlab.importtool.ImportableFileIdentifier.useTextImportTool (line 91)
  In uiimport>useTextImportTool (line 998)
  In uiimport (line 237) 
Warning: Unable to read some of the variables due to unknown MAT-file error.
> In matfinfo (line 9)
  In finfo (line 118)
  In uiimport/gatherFilePreviewData (line 416)
  In uiimport (line 245) 
Error using load
Number of columns on line 2 of ASCII file D:\net00.mat must be the same as previous lines.
Error in uiimport/runImportdata (line 467)
                    datastruct = load('-ascii', fileAbsolutePath);
Error in uiimport/gatherFilePreviewData (line 435)
        [datastruct, textDelimiter, headerLines]= runImportdata(fileAbsolutePath,type);
Error in uiimport (line 245)

Do you have any good Suggestions? Thanks.

Comment on Undocumented classdef attributes by Maarten van der Seijs Wed, 28 Mar 2018 11:12:51 +0000 I’ve been looking for ways to define custom attributes for classes and class methods/properties. I’ve noticed that some internal matlab classes define additional attributes, such as the unit test classes derived from matlab.unittest.TestCase. This can be nicely observed from its meta class:

>> mTestClass = meta.class.fromName('matlab.unittest.TestCase');
>> mTestMethod = mClass.MethodList(1)
mTestMethod = 
  method with properties:
                    Test: 0
         TestMethodSetup: 0
      TestMethodTeardown: 0
          TestClassSetup: 0
       TestClassTeardown: 0
    ParameterCombination: ''
                TestTags: {}
                    Name: 'TestCase'
             Description: ''
     DetailedDescription: ''

The top 7 properties correspond to the method attributes that are available in the method definition blocks, for classes derived from matlab.unittest.TestCase. Apparently these have been added by subclassing the meta.method object to the new matlab.unittest.meta.method, which is indeed the meta class that is returned for classes derived from the superclass matlab.unittest.TestCase.

My question is: do you know of any (undocumented) means to define such attributes ourselves, such that you could do something like this?

classdef MyClass < MyBaseClass
    methods (CustomAttribute = "Custom attribute value")

Any insight or directions would be highly appreciated!

Comment on Serializing/deserializing Matlab data by Yair Altman Wed, 28 Mar 2018 10:44:07 +0000 @Roc – try to convert your data to int16 before saving, and then convert back to uint8 after loading:

netByte = getByteStreamFromArray(net);
netByteSaved = int16(netByte);  % convert to int16
save(filename, 'netByteSaved');
fileData = load(filename);
netByte2 = uint8(fileData.netByteSaved);  % convert back to uint8
net2 = getArrayFromByteStream(netByte2);
Comment on Serializing/deserializing Matlab data by Roc Woods Wed, 28 Mar 2018 10:10:10 +0000 Thanks Yair, this would be very useful. but, there seems to be a bug for some objects to be deserialized with getArrayFromByteStream in deployed mode (dll). Take the AlexNet(we can get the alexnet from Add-On Explorer)for example: when we serialize and deserialized alexnet using the following code:

net = alexnet;
netByte = getByteStreamFromArray(net);
net2 = getArrayFromByteStream(netByte);

it performs well in both MATLAB or deployed mode.

but if we save netByte in a mat file in advance, then it does not work in dll mode:

netByte = load('netByte.mat');
netByte = netByte.netByte;
net2 = getArrayFromByteStream(netByte);
save D:\net2.mat net2

We can not load the net2.mat. It doesn’t look like to be created correctly.

Do you have any ideas for solving this problem?


Comment on Auto-completion widget by Yair Altman Tue, 27 Mar 2018 17:55:40 +0000 @Eric – read my answer above

Comment on Auto-completion widget by Eric Alexander Tue, 27 Mar 2018 17:35:13 +0000 Yair,

I am trying to implement something very similar in a GUI I am making but after creating the Combo Box and running your above code, I am getting an error at the line:

assetClassIdx = getappdata(handles.cbAssetClass, ‘assetClassIdx’);

because there is no variable “handles.” What does this variable need to be?