Comments for Undocumented Matlab Charting Matlab's unsupported hidden underbelly Sun, 22 Oct 2017 06:39:14 +0000 hourly 1 Comment on Customizing uitree nodes – part 2 by Yair Altman Sun, 22 Oct 2017 06:39:14 +0000 @Paul – you can check each node’s SelectionState property value, and you can compare it to com.mathworks.mwswing.checkboxtree.SelectionState.SELECTED, .NOT_SELECTED or .MIXED. For example:

if jRoot.getSelectionState == com.mathworks.mwswing.checkboxtree.SelectionState.NOT_SELECTED, ...
Comment on Tips for accelerating Matlab performance by Yair Altman Sun, 22 Oct 2017 06:19:24 +0000 @Collin – I’ll be happy to assist you by spending time to investigate this for you, but I would naturally expect to be compensated for my time and expertise. Email me (altmany at gmail) if you’re interested.

Comment on Tips for accelerating Matlab performance by Collin Sat, 21 Oct 2017 21:57:32 +0000 Yair,

Excellent advice as always.

I’m attempting to incorporate a breadcrumb bar into a GUI. After failing to get JIDE’s (com.jidesoft.navigation.BreadcrumbBar) to work, I tried Mathwork’s Addressbar…

vfs = com.mathworks.mlwidgets.explorer.model.vfs.VirtualFileSystem;
extReqistry =  com.mathworks.mlwidgets.explorer.model.ExplorerExtensionRegistry.getInstance;
fileLocation = com.mathworks.matlab.api.explorer.FileLocation(pwd);
navContext = com.mathworks.mlwidgets.explorer.model.navigation.NavigationContext(vfs,extReqistry,fileLocation);
jAddressBar = com.mathworks.mlwidgets.explorer.widgets.address.AddressBar(navContext);

Which seems to look and function correctly. I just cannot figure out how to get the dataChangeNotifiction callbacks in Matlab.
Do you have any suggestions?



Comment on Explicit multi-threading in Matlab part 4 by Yair Altman Sat, 21 Oct 2017 16:45:44 +0000 @Sharavan – yes, as long as you place the code in a Matlab s-function. The syntax should be the same as that shown on this blog.

Comment on Customizing uitree nodes – part 2 by Paul M. Fri, 20 Oct 2017 17:26:33 +0000 Excellent tutorial,

I am using the Matlab built in class (com.mathworks.mwswing.checkboxtree.CheckBoxTree), how do I get a list of which nodes have the check box marked?

If I use:


…from the built-in class example I get a list of the highlighted nodes, not the checked ones.


Comment on Enabling user callbacks during zoom/pan by Thommy Fri, 20 Oct 2017 07:15:09 +0000 Thank you mate, I’ve passed quite some time on that issue. You made my day !

Comment on Explicit multi-threading in Matlab part 4 by sharavan Thu, 19 Oct 2017 14:58:34 +0000 Hello Yair,
Thanks for the brilliant article. Will I be able to call Java extensions from S Functions from Simulink. A very small example would help a lot.

Best Regards

Comment on Sliders in Matlab GUI by Yair Altman Thu, 12 Oct 2017 16:28:40 +0000 @Zach – a slider that only fires when you release the drag handle is the default documented way that Matlab’s slider works. My post is only relevant if you want updates to happen while the handle is being dragged.

Comment on Sliders in Matlab GUI by Zach Mauch Wed, 11 Oct 2017 21:36:52 +0000 I’m using the java slider in a GUI, but I’m getting some weird behavior as I actively slide. I added an edit box to populate the index into for the user. It populates fine when I move the slider one by one or slowly. When I grab it and drag, the callbacks appear to be piling up and the box gets populated with the first index instead of the last.


I drag the slider quickly from 20 to 60. The box will start at 60 and then quickly cycle down to 21.

It is like the entire GUI is having trouble keeping up. Maybe I need to try to up the efficiency processing a little, but I didn’t think I was doing that much.

Anyway, one workaround I thought of was to change it to a callback that will only implement when I release the slider rather than continually implementing it. Any suggestions?

Comment on Faster csvwrite/dlmwrite by Yair Altman Tue, 10 Oct 2017 23:51:29 +0000 @Saket – thanks for sharing, useful indeed

Comment on Parsing XML strings by Yair Altman Tue, 10 Oct 2017 23:44:37 +0000 @Michal – when you say that something “does not work at all” you provide zero information about what you tried to do and what happened. If you expect me to spend time to try to help you, then the minimum that you should do is to spend the time to include useful information that could help diagnose the problem. If you don’t have the time to add this information, then I don’t have the time to assist you, sorry.

Comment on Parsing XML strings by Michal Kvasnicka Mon, 09 Oct 2017 14:16:40 +0000 @Yair Undocumented functionality (first code box) does not work at all (R2017b)!!!
I always got null result. Any workaround?

Comment on Faster csvwrite/dlmwrite by Saket Thu, 05 Oct 2017 07:52:58 +0000 @Andrew, @Yair – Try out the Mex Version of CSV Reader from Stanislaw Adaszewski.

You might need to modify the C – Code as per your need & create a .mex file from the c-code. I have been using it for last 2 Years. This is quick – very quick..!

Comment on Runtime code instrumentation by Mark Whitfield Wed, 04 Oct 2017 17:07:34 +0000 Thank you.

Comment on Faster csvwrite/dlmwrite by Michal Kvasnicka Wed, 04 Oct 2017 09:07:52 +0000 @Yair – thanks for very interesting post!

Any examples how to read/write HUGE text files (CSV) by fread+textscan in chunks?

Comment on An interesting uitree utility by Yair Altman Wed, 04 Oct 2017 08:17:39 +0000 @Peter – Thanks for sharing

Comment on Plot markers transparency and color gradient by FP Wed, 04 Oct 2017 07:34:04 +0000 Is there also a hidden MarkerHandle or something similar for animatedline? Because I get the following error trying the same with animatedline:

No appropriate method, property, or field 'MarkerHandle' for class ''.

Comment on An interesting uitree utility by Peter Cook Tue, 03 Oct 2017 23:09:52 +0000 Yair,
I wrote this to fill a need I’ve had for a lightweight “structure explorer” type utility that lets me navigate a struct quickly without the need to necessarily plot the data. I create the tree as I traverse the structure so I didn’t have to make an ExpandFcn/MousePressedCallback; I also wrote a version that expands all nodes initially but it can be a bit overwhelming for a broad or deep tree (e.g. a struct returned by xml2struct). Maybe you or someone reading this page will find this useful as the original utility doesn’t work in recent MATLAB releases.

function mtree = mapStruct(s)
    hFig1 = figure('pos',[32,32,512,960]);
    hFig1.ToolBar = 'none';
    hFig1.MenuBar = 'none';
    hFig1.Name = 'Struct Explorer';
    hFig1.NumberTitle = 'off';
    root = uitreenode('v0','root','root',[],false);
    mtree = uitree('v0','Root',root,'Parent',hFig1);
    function structTraverse(s,node)
        f = fieldnames(s);
        %explore each field in the input struct s
        for kField = 1 : length(f)
            structField = s.(f{kField}); %structField = getfield(s,f{kField});
            %if struct field is a cell array of structs, convert to struct array IFF structs are identical
            if iscell(structField)
                if all(cellfun(@isstruct,structField))
                        structField = [structField{:}];
                        %add some sort of exception handling
            %if the structure field is also a struct explore each field
            if isstruct(structField) %strcmp(structFieldClass,'struct')
                %determine depth of struct field & enumerate if depth > 1
                structDepth = length(structField);
                if structDepth > 1
                    newNode = uitreenode('v0',f{kField},f{kField},[],false);
                    %if the depth of the structure field is greater than 1
                    %add a blank parent node then add each layer/depth level as a node in the tree
                    for kLayer = 1:structDepth
                        nodeLayerName = sprintf('%s(%d)',f{kField},kLayer);
                        nextNode = uitreenode('v0', nodeLayerName,nodeLayerName,[],false);
                    %if the depth of the structure field is 1 add it as a node
                    nextNode = uitreenode('v0',f{kField},f{kField},[],false);
                %make a node for the variable/attribute and display information about the variable
                newNode = uitreenode('v0',f{kField},f{kField},[],false);
                [nRow,nCol] = size(structField);
                structFieldClass = class(structField);
                if isempty(structField)
                    displayString = 'empty';
                elseif nRow==1 && ischar(structField)
                    displayString = structField;
                elseif nRow==1 && nCol==1 && any(strcmp(structFieldClass,{'single','double','logical'}))
                    displayString = sprintf('%f',structField);
                    displayString = sprintf('%dx%d %s',nRow,nCol,structFieldClass);
                nextNode = uitreenode('v0',displayString,displayString,[],true);
    mtree.Position(3) = 512;
Comment on Faster csvwrite/dlmwrite by Yair Altman Tue, 03 Oct 2017 18:09:18 +0000 @Andrew – my advise is to read the entire CSV file into memory (a long string) using fread and then parse the string, for example using textscan. This works well with files that are not huge; with huge files you may want to read them in chunks.

Comment on Runtime code instrumentation by Yair Altman Tue, 03 Oct 2017 18:03:11 +0000 @Mark – I meant p-coded code