Comments for Undocumented Matlab https://undocumentedmatlab.com Charting Matlab's unsupported hidden underbelly Sun, 22 Oct 2017 06:39:14 +0000 hourly 1 https://wordpress.org/?v=4.4.1 Comment on Customizing uitree nodes – part 2 by Yair Altmanhttps://undocumentedmatlab.com/blog/customizing-uitree-nodes-2#comment-415343 Sun, 22 Oct 2017 06:39:14 +0000 http://undocumentedmatlab.com/?p=1850#comment-415343 @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 Altmanhttps://undocumentedmatlab.com/blog/tips-for-accelerating-matlab-performance#comment-415342 Sun, 22 Oct 2017 06:19:24 +0000 http://undocumentedmatlab.com/?p=7099#comment-415342 @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 Collinhttps://undocumentedmatlab.com/blog/tips-for-accelerating-matlab-performance#comment-415324 Sat, 21 Oct 2017 21:57:32 +0000 http://undocumentedmatlab.com/?p=7099#comment-415324 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);
%..........................
jhFrame.add(jAddressBar.getComponent,'North');

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?

Sincerly

Collin

]]>
Comment on Explicit multi-threading in Matlab part 4 by Yair Altmanhttps://undocumentedmatlab.com/blog/explicit-multi-threading-in-matlab-part4#comment-415306 Sat, 21 Oct 2017 16:45:44 +0000 http://undocumentedmatlab.com/?p=4688#comment-415306 @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.https://undocumentedmatlab.com/blog/customizing-uitree-nodes-2#comment-415242 Fri, 20 Oct 2017 17:26:33 +0000 http://undocumentedmatlab.com/?p=1850#comment-415242 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:

jCheckBoxTree.getSelectionPaths()

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

-Thanks

]]>
Comment on Enabling user callbacks during zoom/pan by Thommyhttps://undocumentedmatlab.com/blog/enabling-user-callbacks-during-zoom-pan#comment-415223 Fri, 20 Oct 2017 07:15:09 +0000 http://undocumentedmatlab.com/?p=6043#comment-415223 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 sharavanhttps://undocumentedmatlab.com/blog/explicit-multi-threading-in-matlab-part4#comment-415200 Thu, 19 Oct 2017 14:58:34 +0000 http://undocumentedmatlab.com/?p=4688#comment-415200 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
Sharavan

]]>
Comment on Sliders in Matlab GUI by Yair Altmanhttps://undocumentedmatlab.com/blog/sliders-in-matlab-gui#comment-414863 Thu, 12 Oct 2017 16:28:40 +0000 http://undocumentedmatlab.com/?p=5827#comment-414863 @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 Mauchhttps://undocumentedmatlab.com/blog/sliders-in-matlab-gui#comment-414837 Wed, 11 Oct 2017 21:36:52 +0000 http://undocumentedmatlab.com/?p=5827#comment-414837 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.

Example:

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 Altmanhttps://undocumentedmatlab.com/blog/faster-csvwrite-dlmwrite#comment-414780 Tue, 10 Oct 2017 23:51:29 +0000 http://undocumentedmatlab.com/?p=7080#comment-414780 @Saket – thanks for sharing, useful indeed

]]>
Comment on Parsing XML strings by Yair Altmanhttps://undocumentedmatlab.com/blog/parsing-xml-strings#comment-414779 Tue, 10 Oct 2017 23:44:37 +0000 http://undocumentedmatlab.com/?p=6838#comment-414779 @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 Kvasnickahttps://undocumentedmatlab.com/blog/parsing-xml-strings#comment-414689 Mon, 09 Oct 2017 14:16:40 +0000 http://undocumentedmatlab.com/?p=6838#comment-414689 @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 Sakethttps://undocumentedmatlab.com/blog/faster-csvwrite-dlmwrite#comment-414481 Thu, 05 Oct 2017 07:52:58 +0000 http://undocumentedmatlab.com/?p=7080#comment-414481 @Andrew, @Yair – Try out the Mex Version of CSV Reader from Stanislaw Adaszewski. http://adared.ch/efficient-csv-reader-for-matlab/

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 Whitfieldhttps://undocumentedmatlab.com/blog/runtime-code-instrumentation#comment-414443 Wed, 04 Oct 2017 17:07:34 +0000 http://undocumentedmatlab.com/?p=7063#comment-414443 Thank you.

]]>
Comment on Faster csvwrite/dlmwrite by Michal Kvasnickahttps://undocumentedmatlab.com/blog/faster-csvwrite-dlmwrite#comment-414421 Wed, 04 Oct 2017 09:07:52 +0000 http://undocumentedmatlab.com/?p=7080#comment-414421 @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 Altmanhttps://undocumentedmatlab.com/blog/interesting-uitree-utility#comment-414419 Wed, 04 Oct 2017 08:17:39 +0000 http://undocumentedmatlab.com/?p=2218#comment-414419 @Peter – Thanks for sharing

]]>
Comment on Plot markers transparency and color gradient by FPhttps://undocumentedmatlab.com/blog/plot-markers-transparency-and-color-gradient#comment-414417 Wed, 04 Oct 2017 07:34:04 +0000 http://undocumentedmatlab.com/?p=5262#comment-414417 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 'matlab.graphics.animation.AnimatedLine'.

]]>
Comment on An interesting uitree utility by Peter Cookhttps://undocumentedmatlab.com/blog/interesting-uitree-utility#comment-414405 Tue, 03 Oct 2017 23:09:52 +0000 http://undocumentedmatlab.com/?p=2218#comment-414405 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))
                    try
                        structField = [structField{:}];
                    catch
                        %add some sort of exception handling
                    end
                end
            end
 
            %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);
                    node.add(newNode);
                    %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);
                        newNode.add(nextNode);
                        structTraverse(structField(kLayer),nextNode)
                    end
                else
                    %if the depth of the structure field is 1 add it as a node
                    nextNode = uitreenode('v0',f{kField},f{kField},[],false);
                    node.add(nextNode);
                    structTraverse(structField,nextNode)
                end
            else
                %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);
                else
                    displayString = sprintf('%dx%d %s',nRow,nCol,structFieldClass);
                end
                nextNode = uitreenode('v0',displayString,displayString,[],true);
                newNode.add(nextNode);
                node.add(newNode);
            end
        end
    end
 
    structTraverse(s,root)
    mtree.reloadNode(root)
    mtree.Position(3) = 512;
 
end
]]>
Comment on Faster csvwrite/dlmwrite by Yair Altmanhttps://undocumentedmatlab.com/blog/faster-csvwrite-dlmwrite#comment-414392 Tue, 03 Oct 2017 18:09:18 +0000 http://undocumentedmatlab.com/?p=7080#comment-414392 @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 Altmanhttps://undocumentedmatlab.com/blog/runtime-code-instrumentation#comment-414391 Tue, 03 Oct 2017 18:03:11 +0000 http://undocumentedmatlab.com/?p=7063#comment-414391 @Mark – I meant p-coded code

]]>