Comments for Undocumented Matlab http://undocumentedmatlab.com Charting Matlab's unsupported hidden underbelly Sat, 25 Feb 2017 05:40:49 +0000 hourly 1 https://wordpress.org/?v=4.4.1 Comment on Waterloo graphics by Mike Peschelhttp://undocumentedmatlab.com/blog/waterloo-graphics#comment-401154 Sat, 25 Feb 2017 05:40:49 +0000 http://undocumentedmatlab.com/?p=3361#comment-401154 Hi Malcolm,
is there an equivalent to Matlab’s image() or imagesc() function in Waterloo?
Thanks!

]]>
Comment on Continuous slider callback by Felixhttp://undocumentedmatlab.com/blog/continuous-slider-callback#comment-401022 Thu, 23 Feb 2017 16:18:26 +0000 http://undocumentedmatlab.com/?p=1052#comment-401022 May add a listener to ButtonDownFcn/ButtonUpFcn ? I tried various events but only got errors like:

Event 'ButtonDownFcn' is not defined for class
'matlab.ui.control.UIControl'.
]]>
Comment on Continuous slider callback by Felixhttp://undocumentedmatlab.com/blog/continuous-slider-callback#comment-401021 Thu, 23 Feb 2017 16:14:11 +0000 http://undocumentedmatlab.com/?p=1052#comment-401021 Hello,

I have some performance issues when using the addlistener in addition to WindowButtonMotionFcn:

function temp
   F = figure();
   set(F,'WindowButtonMotionFcn',@Cursor);
   H = uicontrol(F,'Style','slider');
   addlistener(H, 'Value', 'PostSet',@getSliderValue);
end
function getSliderValue(hObj,event)
   get(event.AffectedObject,'Value')
end
function Cursor(hObj,event)
   disp('move')
end

Is there a way to suppress the WindowButtonMotionFcn of the figure during the continuous slider callback? I tried using the WindowButtonDownFcn/WindowButtonUpFcn to remove/add the WindowButtonMotionFcn, but WindowButtonDownFcn nor ButtonDownFcn is called when the slider property ‘Enable’ is set ‘on’. Using ‘inactive’ first would a require a second click to tell Matlab to drag the slider…

function temp
   F = figure();
   set(F,'WindowButtonMotionFcn',@Cursor);
   set(F,'WindowButtonDownFcn',@ButtonDown);
   set(F,'WindowButtonUpFcn',@ButtonUp);
   H = uicontrol(F,'Style','slider');
   addlistener(H, 'Value', 'PostSet',@getSliderValue);
end
function getSliderValue(hObj,event)
   get(event.AffectedObject,'Value')
end
function Cursor(hObj,event)
   disp('move')
end
function ButtonDown(hObj,event)
   set(gcf,'WindowButtonMotionFcn',[]);
end
function ButtonUp(hObj,event)
   set(gcf,'WindowButtonMotionFcn',@Cursor);
end

Thanks, Felix

]]>
Comment on Color selection components by Meadehttp://undocumentedmatlab.com/blog/color-selection-components#comment-400929 Wed, 22 Feb 2017 16:14:26 +0000 http://undocumentedmatlab.com/?p=2322#comment-400929 Yair,

Another super useful post I’m just now finding!

I have embedded this color picker within a context menu of a GUI I’ve built.
My question is this:
Is it possible to trigger a callback when the user clicks ‘OK’ in the widget?
Using the code snippet you provided for @Red Kim, hopefully my intention is clear.

Thanks so much for all the great insights.
Best,
meade

import com.mathworks.mlwidgets.graphics.ColorPicker
cp = ColorPicker(ColorPicker.AUTO, ColorPicker.LINE_ICON, '');
[jcp,hcontainer] = javacomponent(cp,[],gcf);   % Need to trigger callback on selection here!
 
% function MyCallback(hObj,evt)
color = cp.getValue;  % a java.awt.Color object % This should be within the callback
color = cp.getValue.getColorComponents([])' * 255;   % an [R,G,B] array of values
% Do something with the color
% end %MyCallback
]]>
Comment on treeTable by Daniele F.http://undocumentedmatlab.com/blog/treetable#comment-400838 Tue, 21 Feb 2017 10:15:26 +0000 http://undocumentedmatlab.com/?p=4062#comment-400838 Dear Yair

You’re completely right.
Thanks for having taken the time to answer to such a stupid question :)

]]>
Comment on Controlling plot data-tips by Yair Altmanhttp://undocumentedmatlab.com/blog/controlling-plot-data-tips#comment-400619 Sat, 18 Feb 2017 19:16:50 +0000 http://undocumentedmatlab.com/?p=2432#comment-400619 @Michael –

set(hLines,'HitTest','off')
]]>
Comment on Controlling plot data-tips by Michaelhttp://undocumentedmatlab.com/blog/controlling-plot-data-tips#comment-400515 Fri, 17 Feb 2017 15:10:55 +0000 http://undocumentedmatlab.com/?p=2432#comment-400515 Dear Yair
I would like to make some of the lines on the plot “unaccessible” / “invisible” for the datacursor mode
(Thus, I want the possibility to place the data cursor only on part of the lines that appear on the plot).
How can I do that, please?
Thank You
Michael

]]>
Comment on Multi-line uitable column headers by Shihttp://undocumentedmatlab.com/blog/multi-line-uitable-column-headers#comment-400507 Fri, 17 Feb 2017 12:56:35 +0000 http://undocumentedmatlab.com/?p=2976#comment-400507 Hi,Yair
Thanks you createTable.m and it is really work using uicontextmenu in uitree.while I find a bug, I really can set uicontextmenu in old uitable through createTable.m. In container it really have a uicontextmenu defined by program. but in the uitable, it shows also the default uicontextmenu. How can show the Custom menu?

]]>
Comment on Additional license data by Yair Altmanhttp://undocumentedmatlab.com/blog/additional-license-data#comment-400481 Fri, 17 Feb 2017 07:41:11 +0000 http://undocumentedmatlab.com/?p=6852#comment-400481 @Brad – This is the graphics package which is part of the Lightspeed toolbox by Tom Minka.

]]>
Comment on Additional license data by Brad Stiritzhttp://undocumentedmatlab.com/blog/additional-license-data#comment-400466 Fri, 17 Feb 2017 03:17:15 +0000 http://undocumentedmatlab.com/?p=6852#comment-400466 Hi Yair,

I noticed “Statistical Graphics Toolbox” in your version listing. What is that, if I may ask, please? I couldn’t find any info on my own. Thanks in advance.

]]>
Comment on Detecting window focus events by Daniel Castanohttp://undocumentedmatlab.com/blog/detecting-window-focus-events#comment-400400 Thu, 16 Feb 2017 09:41:18 +0000 http://undocumentedmatlab.com/?p=584#comment-400400 Well, I found a solution (R2016b) by trial and error for very simple situations, i.e., just one axes inside the figure.
I just check the number of components in jAxis and grab the last one.

hFig = figure; 
h = axes(hFig);
plot(rand(100,1),'Parent',h);
jFig = get(hFig, 'JavaFrame');
jAxis = jFig.getAxisComponent;
 
n = jAxis.getComponentCount;
disp(n);
jAxis.grabFocus();
drawnow; % will not work without this
n = jAxis.getComponentCount;
disp(n);
 
set(jAxis.getComponent(n-1),'FocusGainedCallback',@(x,y)disp('in focus'));
set(jAxis.getComponent(n-1),'FocusLostCallback',  @(x,y)disp('... out'));

Note that this is mainly cargo cult: I have no idea why I need to grab the focus and force a redraw for this to work. Still would be thankful if somebody comes up with a better, explainable solution, because the one I suggest here does not work for more complicated situations, such as GUIs with multiple panels and changing number of elements…

]]>
Comment on Additional license data by Collinhttp://undocumentedmatlab.com/blog/additional-license-data#comment-400360 Thu, 16 Feb 2017 02:39:14 +0000 http://undocumentedmatlab.com/?p=6852#comment-400360 This may get you what you want

function out = getInstalled()
    % Problem with the support_packages implementor
    knowGoodTypes = {'toolbox','app','product','zip'};
    out = {};
    k = 1;
 
    % Get implementors
    jImplementors = com.mathworks.addons_common.AddonManagerFactory.getImplementors();
    pause(0.5);
 
    iter = jImplementors.listIterator;
    while iter.hasNext
        jImp = iter.next;
        type = char(jImp.getAddonTypeServiced);
        if ismember(type, knowGoodTypes)
            try
                jInstalledList = jImp.getInstalled;
                lenInstalled = length(jInstalledList);
                for itr = 1 : lenInstalled
                    jInstalled = jInstalledList(itr);
                    itype = char(jInstalled.getInstalledAddOnsMetadataToBeSentToManager.getDisplayType);
                    iname = char(jInstalled.getName);
                    iver =  char(jInstalled.getVersion);
                    idate = char(jInstalled.getInstalledDate.toString);
                    out{k,1} = [itype,' : ',iname,' ', iver,' ', idate];
                    k = k+1;
                end
            catch
            end
        end
    end
 
end
]]>
Comment on Uitable sorting by shihttp://undocumentedmatlab.com/blog/uitable-sorting#comment-400355 Thu, 16 Feb 2017 01:38:05 +0000 http://undocumentedmatlab.com/?p=2391#comment-400355 THanks ,it really worked when I didn’t use ColoredFieldCellRenderer.
it may be the question I use the ColoredFieldCellRenderer to Rendering the cell ,and it shows this Exception :
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at ColoredFieldCellRenderer.getTableCellRendererComponent(ColoredFieldCellRenderer.java:101)
at javax.swing.JTable.prepareRenderer(Unknown Source)
at javax.swing.JTable.getToolTipText(Unknown Source)
at javax.swing.ToolTipManager$insideTimerAction.actionPerformed(Unknown Source)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I find the jtable.getModel().getDataVector() can shows correct data in jtable.getModel().getDataVector(),while it cannot propagate from the jtable model to the mtable object。

]]>
Comment on Additional license data by Yair Altmanhttp://undocumentedmatlab.com/blog/additional-license-data#comment-400320 Wed, 15 Feb 2017 18:52:25 +0000 http://undocumentedmatlab.com/?p=6852#comment-400320 @Mikhail – yes, but (alas) without expiration dates…

]]>
Comment on Additional license data by Mikhailhttp://undocumentedmatlab.com/blog/additional-license-data#comment-400318 Wed, 15 Feb 2017 18:45:22 +0000 http://undocumentedmatlab.com/?p=6852#comment-400318 Try “ver -support” to get a listing with license numbers for each toolbox.

]]>
Comment on Detecting window focus events by Daniel Castanohttp://undocumentedmatlab.com/blog/detecting-window-focus-events#comment-400310 Wed, 15 Feb 2017 16:59:06 +0000 http://undocumentedmatlab.com/?p=584#comment-400310 Same problem here :-( … so frustrating, as other callbacks as for instance:

set(jAxis.getComponent(0),'MouseMovedCallback',@(x,y)disp('ab'));

work fine after adding axes to the figure. I really hope that somebody comes up with a solution.

]]>
Comment on treeTable by Yair Altmanhttp://undocumentedmatlab.com/blog/treetable#comment-400243 Tue, 14 Feb 2017 17:31:41 +0000 http://undocumentedmatlab.com/?p=4062#comment-400243 jTable.setValueAt() expects 3 input parameters, not 1.

General note: This is not a blog about Java or JTable, but on Matlab. You really need to search for answers about JTable and such in Java-related sites online – there are plenty of those around, Google would have given you the answer in less time than it took you to write your comment…

]]>
Comment on treeTable by Daniele F.http://undocumentedmatlab.com/blog/treetable#comment-400230 Tue, 14 Feb 2017 15:18:54 +0000 http://undocumentedmatlab.com/?p=4062#comment-400230 Dear Yair

Thanks for your answer. OK, so I tried the function with the wrong data model.

As far as I’ve understood, the java object created with the treeTable function is of class GroupTable.
Now on http://www.jidesoft.com/javadoc/com/jidesoft/grid/GroupTable.html it seems to me that the method setValueAt should be inherited from theclass javax.swing.JTable, but I’m not able to change the values on the table with this method.
E.g. for the command “handles.jtable.setValueAt(2)” the result is:
No method ‘setValueAt’ with matching signature found for class ‘com.jidesoft.grid.GroupTable’.

So now if I want to modify the values on the table, I’m modifying a saved *.mat file and I upload it for every modification, that seems to me not very efficient.

Can I ask you what am I missing or how can I directly modify the jtable?
Many thanks in advance
Daniele

]]>
Comment on Parsing XML strings by americanlamboard.comhttp://undocumentedmatlab.com/blog/parsing-xml-strings#comment-400208 Tue, 14 Feb 2017 09:55:33 +0000 http://undocumentedmatlab.com/?p=6838#comment-400208 @shsteimer I am passing in xml string and it is returning null. It does not throw any exception. What must be wrong?

]]>
Comment on Uitable sorting by Yair Altmanhttp://undocumentedmatlab.com/blog/uitable-sorting#comment-399902 Fri, 10 Feb 2017 10:27:38 +0000 http://undocumentedmatlab.com/?p=2391#comment-399902 data = cell(mtable.getData) should be used but you might need to pause(0.01) to let the data updates propagate from the jtable model to the mtable object.

]]>