Comments for Undocumented Matlab https://undocumentedmatlab.com Charting Matlab's unsupported hidden underbelly Mon, 19 Feb 2018 21:36:50 +0000 hourly 1 https://wordpress.org/?v=4.4.1 Comment on Adding custom properties to GUI objects by Yaroslavhttps://undocumentedmatlab.com/blog/adding-custom-properties-to-gui-objects#comment-419230 Mon, 19 Feb 2018 21:36:50 +0000 https://undocumentedmatlab.com/?p=7324#comment-419230 Hi Yair,

Kudos for bringing up this Sealed issue; I couldn’t have agreed with you more. It is indeed a perplexing decision that hampers one’s work.

I have first encountered this problem while updating the old Cursorbar to the new HG2 engine. Since Cursorbar needed — on top of a plethora of new properties — events and methods with arguments, and since it had to be “real time,” the simple solution of addprop just wouldn’t suffice. It would have been much easier to subclass either Group or some other handle graphics class; alas, being not the case, I had to wiggle myself around to keep the desired behavior and compatibility with handle graphics. As you can imagine, it came with some cost, and some things still don’t work properly as a result.

I believe the Matlab community should press strongly on this matter. Maybe, a shared “new functionality” request between many people or a petition of some sort will do the trick. In any case, it would help to hear a clarification from Mathworks about this decision; perhaps, they have some reasons we’re unaware of.

Cheers and keep up the good work.

]]>
Comment on Explicit multi-threading in Matlab part 1 by Peymanhttps://undocumentedmatlab.com/blog/explicit-multi-threading-in-matlab-part1#comment-419205 Sun, 18 Feb 2018 20:33:39 +0000 http://undocumentedmatlab.com/?p=4659#comment-419205 Thanks Yair. Clearing java solved the problem.

]]>
Comment on Explicit multi-threading in Matlab part 1 by Yair Altmanhttps://undocumentedmatlab.com/blog/explicit-multi-threading-in-matlab-part1#comment-419185 Sat, 17 Feb 2018 17:05:38 +0000 http://undocumentedmatlab.com/?p=4659#comment-419185 @Peyman – it’s probably due to one of the possible reasons that I listed here: https://undocumentedmatlab.com/blog/java-class-access-pitfalls

]]>
Comment on JMI – Java-to-Matlab Interface by Yair Altmanhttps://undocumentedmatlab.com/blog/jmi-java-to-matlab-interface#comment-419184 Sat, 17 Feb 2018 17:00:48 +0000 http://undocumentedmatlab.com/?p=1279#comment-419184 @Andrew – I fixed the MatlabControl link to its new home on GitHub

]]>
Comment on Explicit multi-threading in Matlab part 1 by Peymanhttps://undocumentedmatlab.com/blog/explicit-multi-threading-in-matlab-part1#comment-419169 Fri, 16 Feb 2018 23:34:20 +0000 http://undocumentedmatlab.com/?p=4659#comment-419169 Mybe important: I’m using matlab R2008a and jdk 1.6.0 (both matlab and compilation)

]]>
Comment on Explicit multi-threading in Matlab part 1 by Peymanhttps://undocumentedmatlab.com/blog/explicit-multi-threading-in-matlab-part1#comment-419168 Fri, 16 Feb 2018 23:29:29 +0000 http://undocumentedmatlab.com/?p=4659#comment-419168 Thank you for the post. It seems to be the exact solution I was looging for but I cannot start the Thread like you showed above. I get the error message:

??? Undefined function or method 'start' for input arguments of type 'ParallelPortReaderThread'.
Error in ==> testThread at 8
start(ParallelPortReaderThread(rr_intervals));

This is my Matlab code:

import java.lang.Thread;
import java.util.LinkedList;
rr_intervals = LinkedList();
for i = 1:10
    rr_intervals.add(0);
end
javaaddpath 'C:\Documents and Settings\user\My Documents\MATLAB\Marieke_Experiment';
start(ParallelPortReaderThread(rr_intervals));
%ParallelPortReaderThread pThr = new ParallelPortReaderThread(rr_intervals);
%pThr.start();

And this my java class:

import java.util.Random;
import java.util.LinkedList;
import java.lang.Thread;
 
public class ParallelPortReaderThread extends Thread {
 
    private LinkedList rrIntervals;
 
    public ParallelPortReaderThread(LinkedList queue) {
        this.rrIntervals = queue;
    }
 
    @Override
    public void run() {
        Random random = new Random();
        long x = (long) (800 + 200 * random.nextFloat());
        rrIntervals.remove();
        rrIntervals.add(x);
	try {
           Thread.sleep(x);
        } catch (InterruptedException ie) {
           ie.printStackTrace();
        }
    }
 
    public LinkedList getRrIntervals() {
        return rrIntervals;
    }
}

I’d be very thankful about any help and/or advice

]]>
Comment on JMI – Java-to-Matlab Interface by Andrew Jankehttps://undocumentedmatlab.com/blog/jmi-java-to-matlab-interface#comment-419146 Thu, 15 Feb 2018 18:03:50 +0000 http://undocumentedmatlab.com/?p=1279#comment-419146 Very useful post! I’ll be using this in one of my current projects.

BTW, it looks like the “MatlabControl” link in the fifth paragraph is broken. It’s pointing to googlecode.com, which is defunct. Could you update the link to MatlabControl’s current home?

]]>
Comment on Uitab customizations by Yair Altmanhttps://undocumentedmatlab.com/blog/uitab-customizations#comment-419096 Mon, 12 Feb 2018 17:36:30 +0000 http://undocumentedmatlab.com/?p=1959#comment-419096 @Eric – of course, you can use HTML, much as for uitables (as I explained here)

uitab('Title','<html>Line #1<br/>Line #2')

Add a <center> tag if you want the tab label to be centered:

uitab('Title','<html><center>Line #1<br/>Line #2')
]]>
Comment on Uitab customizations by Eric Alexanderhttps://undocumentedmatlab.com/blog/uitab-customizations#comment-419094 Mon, 12 Feb 2018 16:41:16 +0000 http://undocumentedmatlab.com/?p=1959#comment-419094 Yair,

Do you know of any means to create a uitab with two lines of text that are on top of one another. Uitab does not accept cell arrays when called the “Title” property i.e. uitab(‘Title’,{‘Cat’;’Dog’}) gives an error. Even when doing uitab(‘Title’,[‘Cat’;’Dog’]) creates a tab with the title ‘CDaotg’ for some reason. Any insight would be helpful.

-Eric

]]>
Comment on Uitable cell colors by Bryanhttps://undocumentedmatlab.com/blog/uitable-cell-colors#comment-418990 Wed, 07 Feb 2018 21:20:57 +0000 http://undocumentedmatlab.com/?p=2476#comment-418990 While I certainly respect Yair’s need to be compensated for his time, I thought it would be worth mentioning what I came up with. I actually linked over to undocumentedmatlab from a post on Mathworks where Yair suggested this page as a solution to a question:
https://www.mathworks.com/matlabcentral/answers/25038-how-to-change-each-cell-color-in-a-uitable

Staff member Friedrich’s solution is what I ended up working from. Essentially Matlab UITables natively support html code in each cell, so you can do literally anything you could imagine with that if you do a bit of googling on html tables and formatting. Works like a charm, but it can be very slow in rendering if you have a large table. My table has 13 columns and scrolling down to the bottom of 5000 entries took Matlab nearly 3 whole minutes to catch up rendering. Yair’s solution using a Java renderer is absolutely faster, but it has quite a few issues in more recent versions of Matlab. I experienced random table shading, java console errors on mouse-over, cell text all becoming grey, and so on when I tried to implement the code listed above in R2016a.

Hope this helps,
Bryan

]]>
Comment on COM/ActiveX tips & tricks by Yair Altmanhttps://undocumentedmatlab.com/blog/com-activex-tips#comment-418987 Wed, 07 Feb 2018 20:05:10 +0000 http://undocumentedmatlab.com/?p=1781#comment-418987 @Gary – MathWorks constantly change their website without bothering to redirect the old webpages to their new URLs. This is yet another example of this. I fixed the link that you mentioned to the new URL (hopefully it will not be changed again in the near future, but who know). Unfortunately, all the other links in the article that lead to MathWorks webpage are also broken, and I have not fixed them. If anyone has time to search for the new URLs and email me, then I will update them.

]]>
Comment on IP address input control by Peter Cookhttps://undocumentedmatlab.com/blog/ip-address-input-control#comment-418985 Wed, 07 Feb 2018 18:32:36 +0000 https://undocumentedmatlab.com/?p=7313#comment-418985 A quick method to check if a machine is connected to a particular IP address using MATLAB, which is a potentially useful callback for a widget like this (after string verified with IPTextField):

%check to see if user is on corporate ethernet and terminate otherwise
[~,dosReply] = dos('ping 12.34.56.78');
[~,~,noPacket] = regexp(dosReply,'Received = \d','match');
noPacket = str2double(dosReply(noPacket));
if lt(noPacket,2)
    uiwait(errordlg('Must be Connected to Secure Network'))
    exit
end
]]>
Comment on COM/ActiveX tips & tricks by Gary Rothhttps://undocumentedmatlab.com/blog/com-activex-tips#comment-418953 Tue, 06 Feb 2018 19:23:58 +0000 http://undocumentedmatlab.com/?p=1781#comment-418953 I tried to follow the “well documented” link (https://www.mathworks.com/help/matlab/matlab_external/brd4at8.html) and received the message “The page you were looking for does not exist. Use the search box or browse topics below to find the page you were looking for.”

]]>
Comment on Additional license data by Andrewhttps://undocumentedmatlab.com/blog/additional-license-data#comment-418952 Tue, 06 Feb 2018 17:00:27 +0000 http://undocumentedmatlab.com/?p=6852#comment-418952 Is there any way to return a floating toolbox license without closing the Matlab session? Its not uncommon for me to find that somewhere in my code base I accessed an obscure toolbox which another user now wants to use. At present the only way to that I know of to release the license is to stop what I am doing and shut down Matlab.

]]>
Comment on Adding a context-menu to a uitree by Yair Altmanhttps://undocumentedmatlab.com/blog/adding-context-menu-to-uitree#comment-418946 Tue, 06 Feb 2018 09:20:10 +0000 http://undocumentedmatlab.com/?p=109#comment-418946 @Ian – try to call the Java object’s repaint() method (function), after adding it to the panel (presumably using a call to javacomponent)

]]>
Comment on Uitable cell colors by Yair Altmanhttps://undocumentedmatlab.com/blog/uitable-cell-colors#comment-418945 Tue, 06 Feb 2018 09:16:10 +0000 http://undocumentedmatlab.com/?p=2476#comment-418945 @Martin – as stated in my response to Bryan, I do not work for free: goodwill does not go very far when I need to pay for the groceries and utilities, so I would like to be compensated for my time and expertise. And surely you cannot expect that if Bryan (or anyone else) paid me for a private consulting, that I will just post it here for anyone to see – private consulting remains private.

If this problem affects your professional work, then surely your employer can see the value in paying for a professional solution. You can contact me by email (altmany at gmail.com) or my consulting page.

]]>
Comment on Uitable cell colors by Martinhttps://undocumentedmatlab.com/blog/uitable-cell-colors#comment-418943 Tue, 06 Feb 2018 07:19:33 +0000 http://undocumentedmatlab.com/?p=2476#comment-418943 Hi Bryan, Hi Yair,
I’ve the same problem and would also be very glad to get it running! So please post the solution online and not direct via email to Bryan.
Thanks, regards

]]>
Comment on Solving an mput (FTP) hang problem by Eneshttps://undocumentedmatlab.com/blog/solving-an-mput-ftp-hang-problem#comment-418940 Tue, 06 Feb 2018 05:53:34 +0000 http://undocumentedmatlab.com/?p=5974#comment-418940 I was facing the same problem. When I used dir(f) command the code would just get stuck. Using the line: “sf=struct(f); sf.jobject.enterLocalPassiveMode();” to switch to passive mode as you have pointed out solved my problem. Thank you.

]]>
Comment on Adding a context-menu to a uitree by Ian Alanhttps://undocumentedmatlab.com/blog/adding-context-menu-to-uitree#comment-418938 Tue, 06 Feb 2018 04:29:45 +0000 http://undocumentedmatlab.com/?p=109#comment-418938 Yair,

I am trying to create a uitree one a resizable panel created with your uisplitpane() function.

The tree won’t show up at all in the figure until I drag the divider around with the mouse to resize the panes, and then it shows up like it should. Do you have any suggestions on how I could fix this?

I am using MATLAB 2011a, if it matters.

]]>
Comment on Matlab and the Event Dispatch Thread (EDT) by Jim Hokansonhttps://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt#comment-418913 Mon, 05 Feb 2018 04:46:43 +0000 http://undocumentedmatlab.com/?p=1198#comment-418913 Hi Yair,

I’m interested in the last little bit on the callbackOnEDTQueue() function at the end. In testing this seems to solve my problem of trying to delay running a computation until some later point in time, allowing the rest of the axes to render following a xlim change.
https://www.mathworks.com/matlabcentral/answers/368964-queue-addlistener-events-or-place-event-on-edt

This seems like an alternative to the following post: https://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events#comment-418911

Where my general use case would be to call the notify event (in the linked blog post) directly from Matlab: i.e. evt.notifyMyTest rather than from Java as the linked post is really about.

Am I understanding the callbackOnEDTQueue() function correctly, that it appears to serve the same functionality as the evt class in the link, without the need for writing a Java class and adding it to the Matlab path?

I guess I am confused by this statement:

%Note that the function is still executing on the main Matlab thread. This
%function just delays when it will be called.

What are the practical implications of that statement?

Thanks as always,
Jim

]]>