Comments for Undocumented Matlab https://undocumentedmatlab.com Charting Matlab's unsupported hidden underbelly Tue, 24 Apr 2018 11:26:06 +0000 hourly 1 https://wordpress.org/?v=4.4.1 Comment on Customizing Workspace context-menu by MatthieuChttps://undocumentedmatlab.com/blog/customizing-workspace-context-menu#comment-424017 Tue, 24 Apr 2018 11:26:06 +0000 http://undocumentedmatlab.com/?p=1943#comment-424017 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 torsion27https://undocumentedmatlab.com/blog/uitable-cell-colors#comment-423919 Mon, 23 Apr 2018 17:19:36 +0000 http://undocumentedmatlab.com/?p=2476#comment-423919 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)
tabledata=get(handles.uitable3,'Data');
 
spalte1=tabledata(:,1) %spalte 1 ist die ersrte spalte mit den checkboxen
spalte2=tabledata(:,2)
 
zeilenanzahl=length(tabledata); 
 
% uitablehandles=findobj(handles.uitable3);
for j = 1:1:zeilenanzahl %für zeile 1 bis ende
   if (spalte1{j,1}==1)   
      tabledata{j,2}=spalte2{j,1}
      set(handles.uitable3,'BackgroundColor',[0 1 0]) 
   end
   for j = 1:1:zeilenanzahl  
      if (tabledata{j,1}==0) 
         tabledata{j,2}= set(handles.uitable3,'BackgroundColor',[1 0 0])
      end
   end
end
 
guidata(hObject,handles);
 
% --- 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 MatthieuChttps://undocumentedmatlab.com/blog/customizing-workspace-context-menu#comment-423893 Mon, 23 Apr 2018 12:06:44 +0000 http://undocumentedmatlab.com/?p=1943#comment-423893 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.

Thanks

]]>
Comment on AppDesigner’s mlapp file format by Tomhttps://undocumentedmatlab.com/blog/appdesigner-mlapp-file-format#comment-423415 Tue, 17 Apr 2018 13:43:15 +0000 http://undocumentedmatlab.com/?p=6613#comment-423415 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 Altmanhttps://undocumentedmatlab.com/blog/uitab-colors-icons-images#comment-422357 Thu, 05 Apr 2018 15:05:48 +0000 http://undocumentedmatlab.com/?p=1955#comment-422357 @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 Moghhttps://undocumentedmatlab.com/blog/solving-an-mput-ftp-hang-problem#comment-422296 Thu, 05 Apr 2018 06:44:33 +0000 http://undocumentedmatlab.com/?p=5974#comment-422296 My same problem with “mput” function is solved.
thanks a lot for your useful suggestion.

]]>
Comment on Uitab colors, icons and images by Erichttps://undocumentedmatlab.com/blog/uitab-colors-icons-images#comment-422205 Wed, 04 Apr 2018 17:11:40 +0000 http://undocumentedmatlab.com/?p=1955#comment-422205 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(hTabGroup2,'TabLocation','left')
 
set(tab1,'Title','Tab #1')
]]>
Comment on Waterloo graphics beta by Ninohttps://undocumentedmatlab.com/blog/waterloo-graphics-beta#comment-421950 Mon, 02 Apr 2018 14:34:45 +0000 http://undocumentedmatlab.com/?p=3907#comment-421950 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(JXLabel.java:287)
	at org.jdesktop.swingx.JXLabel.(JXLabel.java:230)
	at kcl.waterloo.graphics.GJAxisPanel.(GJAxisPanel.java:64)
	at kcl.waterloo.graphics.GJAxisPanel.(GJAxisPanel.java:147)
	at kcl.waterloo.graphics.GJAxisPanel.createInstance(GJAxisPanel.java:116)
	at kcl.waterloo.graphics.GJAbstractGraph.createAxes(GJAbstractGraph.java:469)
	at kcl.waterloo.graphics.GJGraphContainer.createInstance(GJGraphContainer.java:73)
 
Error in GXFigure/subplot (line 112)
                varargout{1}=GXGraph(p);
 
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 https://sourceforge.net/p/waterloo/discussion/1113980/thread/d93d580b/ 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,

Nino

]]>
Comment on Serializing/deserializing Matlab data by Yair Altmanhttps://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data#comment-421937 Mon, 02 Apr 2018 10:15:28 +0000 http://undocumentedmatlab.com/?p=4583#comment-421937 @Roc – thanks for the follow-up for the benefit of other readers

]]>
Comment on Serializing/deserializing Matlab data by Roc Woodshttps://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data#comment-421936 Mon, 02 Apr 2018 10:08:08 +0000 http://undocumentedmatlab.com/?p=4583#comment-421936 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 Sharmahttps://undocumentedmatlab.com/blog/ip-address-input-control#comment-421735 Fri, 30 Mar 2018 10:16:12 +0000 https://undocumentedmatlab.com/?p=7313#comment-421735 this is a good method…

]]>
Comment on Waiting for asynchronous events by Yair Altmanhttps://undocumentedmatlab.com/blog/waiting-for-asynchronous-events#comment-421732 Fri, 30 Mar 2018 09:19:54 +0000 http://undocumentedmatlab.com/?p=3017#comment-421732 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 Altmanhttps://undocumentedmatlab.com/blog/waiting-for-asynchronous-events#comment-421731 Fri, 30 Mar 2018 09:15:54 +0000 http://undocumentedmatlab.com/?p=3017#comment-421731 I discussed Ctrl-C interrupts here: https://undocumentedmatlab.com/blog/mex-ctrl-c-interrupt

]]>
Comment on Undocumented classdef attributes by Sam Robertshttps://undocumentedmatlab.com/blog/undocumented-classdef-attributes#comment-421606 Wed, 28 Mar 2018 15:59:32 +0000 http://undocumentedmatlab.com/?p=3315#comment-421606 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 (https://stackoverflow.com/questions/26710767/which-methods-keywords-i-e-testmethodsetup-can-occur-in-matlab/26733613#26733613) 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 Woodshttps://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data#comment-421604 Wed, 28 Mar 2018 15:46:40 +0000 http://undocumentedmatlab.com/?p=4583#comment-421604 @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:

load('D:\net00.mat')
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)
    gatherFilePreviewData(fileAbsolutePath);

Do you have any good Suggestions? Thanks.

]]>
Comment on Undocumented classdef attributes by Maarten van der Seijshttps://undocumentedmatlab.com/blog/undocumented-classdef-attributes#comment-421593 Wed, 28 Mar 2018 11:12:51 +0000 http://undocumentedmatlab.com/?p=3315#comment-421593 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")
       ...
    end
end

Any insight or directions would be highly appreciated!

]]>
Comment on Serializing/deserializing Matlab data by Yair Altmanhttps://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data#comment-421592 Wed, 28 Mar 2018 10:44:07 +0000 http://undocumentedmatlab.com/?p=4583#comment-421592 @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 Woodshttps://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data#comment-421590 Wed, 28 Mar 2018 10:10:10 +0000 http://undocumentedmatlab.com/?p=4583#comment-421590 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?

Thanks!

]]>
Comment on Auto-completion widget by Yair Altmanhttps://undocumentedmatlab.com/blog/auto-completion-widget#comment-421561 Tue, 27 Mar 2018 17:55:40 +0000 http://undocumentedmatlab.com/?p=5763#comment-421561 @Eric – read my answer above

]]>
Comment on Auto-completion widget by Eric Alexanderhttps://undocumentedmatlab.com/blog/auto-completion-widget#comment-421560 Tue, 27 Mar 2018 17:35:13 +0000 http://undocumentedmatlab.com/?p=5763#comment-421560 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?

]]>