Comments for Undocumented Matlab https://undocumentedmatlab.com Professional Matlab consulting, development and training Wed, 16 Jul 2025 14:39:04 +0000 hourly 1 https://wordpress.org/?v=6.7.2 Comment on GUI integrated browser control by Seth https://undocumentedmatlab.com/articles/gui-integrated-browser-control#comment-526940 Wed, 16 Jul 2025 14:39:04 +0000 http://undocumentedmatlab.com/?p=847#comment-526940 In reply to Seth.

@Yair @Collin,

I figured out a sort of work around to pass the information i needed to MATLAB in the newer versions that use the cef browser. I just pass a string of number IDs seperated by a comma. In a javascript function, I collect the text I need from the HTML browser input, create a temporary “textarea” element, write the text in that element, copy that text to the clipboard, and read the clipboard text with MATLAB. I can trigger the function from either HTML or MATLAB click but it is more stable from the MATLAB side. You do need to override the focusable attribute of the MATLAB side java browser like here (https://undocumentedmatlab.com/articles/fixing-a-java-focus-problem).

example javascript code

needed_text = “Hello”;
const temp = document.createElement(“textarea”);
temp.value = needed_text;
temp.style.position = “fixed”;
document.body.appendChild(temp);
temp.focus();
temp.select();
document.execCommand(“copy”);
document.body.removeChild(temp);

]]>
Comment on GUI integrated browser control by Seth https://undocumentedmatlab.com/articles/gui-integrated-browser-control#comment-526932 Mon, 14 Jul 2025 16:43:18 +0000 http://undocumentedmatlab.com/?p=847#comment-526932 In reply to Nicholas.

@Nicholas

I finally figured out a workaround for communicating what I need back to MATLAB in version 2024b using javascript in the HTML browser. Since I was able to get that to work, I next needed to get it compiled.

It worked for me to just replace both the jar and jarext folders in the “C:\Program Files\MATLAB\MATLAB Runtime\R2024b\java” folder with the ones in the “C:\Program Files\MATLAB\R2024b\java” folder. You also have to copy the classpath.txt file from the “C:\Program Files\MATLAB\R2024b\toolbox\local” to the “C:\Program Files\MATLAB\MATLAB Runtime\R2024b\toolbox\local” folder.

There is probably only a certain set of these java files that are necessary for it to work but I just wanted to make sure it worked before traversing down the rabbit trail of missing java classes.

Now I just need to create a wrapper installer for the user to do this on installation. I could probably build it in to the startup of the compiled application but that would probably require an administrator to open the software once after installation.

]]>
Comment on Explicit multi-threading in Matlab part 3 by Yair Altman https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part3#comment-526793 Fri, 06 Jun 2025 12:35:37 +0000 http://undocumentedmatlab.com/?p=4686#comment-526793 In reply to Eric.

@Eric – I suspect the most likely cause is that you’re using R2024b in which the memory model is different from the one used in 2014 when I wrote the original article (over 10 years and ~25 Matlab releases ago!). On R2018a or newer you should avoid using the mxGetPr() method, or at the very least mex-compile using the -R2017b flag. See https://www.mathworks.com/help/matlab/apiref/mxgetpr.html and https://undocumentedmatlab.com/articles/multi-threaded-mex for details. Using a bad reference pointer returned by mxGetPr() may well crash the program.

Possible other causes:
1) You’re using a pre-compiled version of the program that was compiled on another computer that has a non-100%-compatible compiler, or perhaps a different version of Matlab or libmex.dll in the compiled vs. run-time computers.
2) You did not trap your code in a try-catch block. The code calls mexErrMsgIdAndTxt() and this raises an exception that crashes your program since the exception is apparently uncaught. Take a look at the myPosixThread.c source code.
3) Perhaps in R2024b the interface of the mexErrMsgIdAndTxt() MEX function has changed since the time that I wrote the article in 2014. Check your local mex.h file.

]]>
Comment on Explicit multi-threading in Matlab part 3 by Eric https://undocumentedmatlab.com/articles/explicit-multi-threading-in-matlab-part3#comment-526791 Thu, 05 Jun 2025 18:59:11 +0000 http://undocumentedmatlab.com/?p=4686#comment-526791 I am having trouble running the myPosixThread mex-function. MATLAB crashes when I run it the first time or may be at the 2nd and third time. For successful execution, file is successfully created. Can you advise what could have gone wrong? I do see another pthreadVC2.dll in the MinGW compiler, I tried deleting it but still face the same issue.

Unhandled C++ exception detected at 2025-06-05 11:32:12 -0700

% Configuration:
% Crash Decoding : Disabled - No sandbox or build area path
% Crash Mode : continue (default)
% Default Encoding : UTF-8
% Deployed : false
% Graphics Driver : Uninitialized hardware
% Graphics card 1 : NVIDIA ( 0x10de ) NVIDIA RTX 2000 Ada Generation Version 32.0.15.5612 (2024-6-25)
% Graphics card 2 : Microsoft ( 0x0 ) Microsoft Remote Display Adapter Version 10.0.19041.5794 (2006-6-21)
% Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
% MATLAB Architecture : win64
% MATLAB Entitlement ID : 98xxxxx
% MATLAB Root : C:\Program Files\MATLAB\R2024b
% MATLAB Version : 24.2.0.2773142 (R2024b) Update 2
% OpenGL : hardware
% Operating System : Microsoft Windows 10 Enterprise
% Process ID : 14612
% Processor ID : x86 Family 25 Model 24 Stepping 1, AuthenticAMD
% Session Key : 1b61df14-e0d5-49bd-9d0c-9157xxxxxx
% Window System : Version 10.0 (Build 19045)
%
% Fault Count: 1
%
% Abnormal termination:
% Unhandled C++ exception
%
% Current Thread: '' id 29128
%
% Register State (from fault):
% RAX = 0000000000000000 RBX = 00007ff936a6b468
% RCX = 0000000000000000 RDX = 0000000000000000
% RSP = 00000070073fd7f0 RBP = 00000070073ffad9
% RSI = 00000070073fd998 RDI = 0000000019930520
%
% R8 = 0000000000000000 R9 = 0000000000000000
% R10 = 0000000000000000 R11 = 0000000000000000
% R12 = 0000000000000000 R13 = 0000000000000000
% R14 = 0000000000000000 R15 = 0000000000000000
%
% RIP = 00007ff9d743af29 EFL = 00000206
%
% CS = 0033 FS = 0053 GS = 002b
%
% Stack Trace (from fault):
% [ 0] 0x00007ff9d743af29 C:\WINDOWS\System32\KERNELBASE.dll+00241449 RaiseException+00000105
% [ 1] 0x00007ff9ce896720 C:\Program Files\MATLAB\R2024b\bin\win64\VCRUNTIME140.dll+00026400 CxxThrowException+00000144
% [ 2] 0x00007ff9369f529c C:\Program Files\MATLAB\R2024b\bin\win64\libmex.dll+00545436 mexErrMsgIdAndTxt_800+00000220
% [ 3] 0x00007ff8f8c0112c C:\Users\Eric\Documents\MATLAB\PODs\myPosixThread.mexw64+00004396 mexFunction+00000300
% [ 4] 0x00007ff8f8be65bc C:\Program Files\MATLAB\R2024b\bin\win64\pthreadVC2.dll+00026044 pthread_key_delete+00020828
% [ 5] 0x00007ff9d7751bb2 C:\WINDOWS\System32\ucrtbase.dll+00138162 configthreadlocale+00000146
% [ 6] 0x00007ff9d98a7374 C:\WINDOWS\System32\KERNEL32.DLL+00095092 BaseThreadInitThunk+00000020
% [ 7] 0x00007ff9d9c3cc91 C:\WINDOWS\SYSTEM32\ntdll.dll+00314513 RtlUserThreadStart+00000033

]]>
Comment on Customizing uifigures part 1 by Yair Altman https://undocumentedmatlab.com/articles/customizing-uifigures-part-1#comment-526736 Fri, 23 May 2025 15:23:08 +0000 http://undocumentedmatlab.com/?p=6554#comment-526736 In reply to SylvanoMTL.

@SylvanoMTL – try to set the uifigure’s position to (-1000,-1000,100,100) – this will hide the figure, although the user will still see something in the Desktop taskbar.

]]>
Comment on Customizing uifigures part 1 by SylvanoMTL https://undocumentedmatlab.com/articles/customizing-uifigures-part-1#comment-526631 Wed, 07 May 2025 19:55:40 +0000 http://undocumentedmatlab.com/?p=6554#comment-526631 Thanks for this post, I am using the uialert which is a real pain as it always need a uifigure. The uifigure is relatively hugly and the uialert can be closed by closing the figure. There is no way to set the uifigure Visibility to “off” as it hides the uialert.
Resizing the uifigure to the uialert size manually is doable but painful. Especially the title bar is still visible.
Any way to work around this?

]]>
Comment on rmfield performance by Yair Altman https://undocumentedmatlab.com/articles/rmfield-performance#comment-526300 Thu, 16 Jan 2025 15:29:56 +0000 http://undocumentedmatlab.com/?p=6427#comment-526300 In reply to tommsch.

I agree, you have a good point 🙂

]]>
Comment on Minimize/maximize figure window by Alexander L https://undocumentedmatlab.com/articles/minimize-maximize-figure-window#comment-526299 Thu, 16 Jan 2025 14:38:59 +0000 http://undocumentedmatlab.com/?p=2310#comment-526299 For me warning concerning about removing JFrame displayed even if I wrap gcf in handle():

warning(‘off’, ‘MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame’)
jFrame = get(handle(gcf), ‘JavaFrame’)
‘Warning: The JavaFrame figure property will be removed in a future release. For more information see UI Alternatives for MATLAB Apps on mathworks.com.’
jFrame =
com.mathworks.hg.peer.HG2FigurePeer@82c57b3

Workaround for silencing this warning is to issue
warning(‘off’, ‘MATLAB:ui:javaframe:PropertyToBeRemoved’)

before executing get(handle(gcf), ‘JavaFrame’) call.

I’m using Matlab R2024a, but it is seems that it is actual at least for Matlab R2019b (https://neuroimage.usc.edu/forums/t/silencing-matlab-warning-messages-about-javacomponent/22305/2).

]]>
Comment on rmfield performance by tommsch https://undocumentedmatlab.com/articles/rmfield-performance#comment-526298 Thu, 16 Jan 2025 14:30:49 +0000 http://undocumentedmatlab.com/?p=6427#comment-526298 I suggest the name `rmfield_fast`, because after some time one usually forgot that there exists a fast version of `rmfield`. But, if “fast” is appended at the end, then the intellisense-thingy of Matlab will show you the function `rmfield_fast` whenever you type `rmfield`.

]]>
Comment on Serializing/deserializing Matlab data by Cookie https://undocumentedmatlab.com/articles/serializing-deserializing-matlab-data#comment-525412 Mon, 23 Sep 2024 19:38:55 +0000 http://undocumentedmatlab.com/?p=4583#comment-525412 If you have the parallel toolbox there is a method byteArray = distcompserialize64(myData) which appears to function the same as getByteStreamFromArray()> but does not seem to have data size limitations.

MATLAB\R2017b\toolbox\distcomp\distcomp\distcompserialize64.mexw64

There is a function distcompdeserialize() which reconstructs the matlab data from the bytes. Fwiw, getArrayFromByteStream() appears to work on the serialized bytes produced by distcompserialize64 as well. Performance seems to be equivalent for both discompdeserialize() and getArrayFromByteStream().

]]>