Month: May 2025
MATLAB and C++ Automatic coupling
Hi support,
I would like to develop an automatic coupling between C++ and MATLAB .
In simple Word:
* – Import in C++ the data from a .mat file
* – Run the simulation in C++
* – Export the results back in a .mat file
Based on the above details of my case, could you advise me for a way to start with?
Please let me know if you require any further clarifications.
Thank you for your continuous support.
Yahia Alabbasi B.C.Eng (Hons)
Research Assistant- Qatar University-Department of Civil and Architectural EngineeringHi support,
I would like to develop an automatic coupling between C++ and MATLAB .
In simple Word:
* – Import in C++ the data from a .mat file
* – Run the simulation in C++
* – Export the results back in a .mat file
Based on the above details of my case, could you advise me for a way to start with?
Please let me know if you require any further clarifications.
Thank you for your continuous support.
Yahia Alabbasi B.C.Eng (Hons)
Research Assistant- Qatar University-Department of Civil and Architectural Engineering Hi support,
I would like to develop an automatic coupling between C++ and MATLAB .
In simple Word:
* – Import in C++ the data from a .mat file
* – Run the simulation in C++
* – Export the results back in a .mat file
Based on the above details of my case, could you advise me for a way to start with?
Please let me know if you require any further clarifications.
Thank you for your continuous support.
Yahia Alabbasi B.C.Eng (Hons)
Research Assistant- Qatar University-Department of Civil and Architectural Engineering c++, matlab, data import, export MATLAB Answers — New Questions
Can’t use MATLAB on fedora 42
After about 1 minute matlab crashes every time with the following error:
Unable to communicate with required MathWorks services (error 5201).
I have tried reinstalling MathWorks services as suggested elsewhere, and it dind’t change anything.After about 1 minute matlab crashes every time with the following error:
Unable to communicate with required MathWorks services (error 5201).
I have tried reinstalling MathWorks services as suggested elsewhere, and it dind’t change anything. After about 1 minute matlab crashes every time with the following error:
Unable to communicate with required MathWorks services (error 5201).
I have tried reinstalling MathWorks services as suggested elsewhere, and it dind’t change anything. linux, fedora, mathwork services MATLAB Answers — New Questions
How to Resize images stored in matlab.io.datastore.ImageDatastore to [224 224 3]
Hello I’m new in using pretrained networks in MATLAB for Object Detection and I was following a guide in Youtube which uses YOLO for detection. In this guide, it also used the resnet50 pretrained network which has an input layer that expects images of size (224x224x3).
Below is the code:
trainData1 = Data;
%%% Create resnet50 pretrained network
netWidth = 16;
layers = [
imageInputLayer([224 224 3], ‘Name’, ‘input’)
convolution2dLayer(3, netWidth, ‘Padding’,’same’, ‘Name’, ‘convInp’)
batchNormalizationLayer(‘Name’, ‘BNInp’)
reluLayer(‘Name’, ‘reluInp’)
convolutionalUnit(netWidth, 1, ‘S1U1’)
additionLayer(2, ‘Name’, ‘add11’)
reluLayer(‘Name’, ‘relu11’)
convolutionalUnit(netWidth, 1, ‘S1U2’)
additionLayer(2, ‘Name’, ‘add12’)
reluLayer(‘Name’, ‘relu12’)
convolutionalUnit(2*netWidth, 2, ‘S2U1’)
additionLayer(2, ‘Name’, ‘add21’)
reluLayer(‘Name’, ‘relu21’)
convolutionalUnit(2*netWidth , 1, ‘S2U2’)
additionLayer(2, ‘Name’, ‘add22’)
reluLayer(‘Name’, ‘relu22’)
convolutionalUnit(4*netWidth, 2, ‘S3U1’)
additionLayer(2, ‘Name’, ‘add31’)
reluLayer(‘Name’, ‘relu31’)
convolutionalUnit(4*netWidth, 1, ‘S3U2’)
additionLayer(2, ‘Name’, ‘add32’)
reluLayer(‘Name’, ‘relu32’)
averagePooling2dLayer(8, ‘Name’, ‘globalPool’)
fullyConnectedLayer(4, ‘Name’, ‘fcFinal’)
softmaxLayer(‘Name’, ‘softmax’)
classificationLayer(‘Name’, ‘classoutput’)
];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph, ‘reluInp’, ‘add11/in2’);
lgraph = connectLayers(lgraph, ‘relu11’, ‘add12/in2’);
skip1 = [
convolution2dLayer(1,2*netWidth, ‘Stride’, 2, ‘Name’, ‘skipConv1’)
batchNormalizationLayer(‘Name’, ‘skipBN1’)];
lgraph = addLayers(lgraph, skip1);
lgraph = connectLayers(lgraph, ‘relu12’, ‘skipConv1’);
lgraph = connectLayers(lgraph, ‘skipBN1’, ‘add21/in2’);
lgraph = connectLayers(lgraph, ‘relu21’, ‘add22/in2’);
skip2 = [
convolution2dLayer(1, 4*netWidth, ‘Stride’,2, ‘Name’, ‘skipConv2’)
batchNormalizationLayer(‘Name’,’skipBN2′)];
lgraph = addLayers(lgraph, skip2);
lgraph = connectLayers(lgraph, ‘relu22’, ‘skipConv2’);
lgraph = connectLayers(lgraph, ‘skipBN2’, ‘add31/in2’);
%add last identity connection and plot the final layer graph
lgraph = connectLayers(lgraph, ‘relu31’, ‘add32/in2’);
%training options
options = trainingOptions("sgdm", …
‘MiniBatchSize’, 128, …
‘MaxEpochs’, 1, …
‘InitialLearnRate’,1e-4);
% network training
[trainedNet1, traininfo] = trainNetwork(trainData1, lgraph, options);
And the output error is this:
% network training
[trainedNet1, traininfo] = trainNetwork(trainData1, lgraph, options);
Error using trainNetwork
The training images are of size 3024×4032×3 but the input layer expects images of size 224×224×3.
My workspace is this:
Thank You. Hope You Can Help.Hello I’m new in using pretrained networks in MATLAB for Object Detection and I was following a guide in Youtube which uses YOLO for detection. In this guide, it also used the resnet50 pretrained network which has an input layer that expects images of size (224x224x3).
Below is the code:
trainData1 = Data;
%%% Create resnet50 pretrained network
netWidth = 16;
layers = [
imageInputLayer([224 224 3], ‘Name’, ‘input’)
convolution2dLayer(3, netWidth, ‘Padding’,’same’, ‘Name’, ‘convInp’)
batchNormalizationLayer(‘Name’, ‘BNInp’)
reluLayer(‘Name’, ‘reluInp’)
convolutionalUnit(netWidth, 1, ‘S1U1’)
additionLayer(2, ‘Name’, ‘add11’)
reluLayer(‘Name’, ‘relu11’)
convolutionalUnit(netWidth, 1, ‘S1U2’)
additionLayer(2, ‘Name’, ‘add12’)
reluLayer(‘Name’, ‘relu12’)
convolutionalUnit(2*netWidth, 2, ‘S2U1’)
additionLayer(2, ‘Name’, ‘add21’)
reluLayer(‘Name’, ‘relu21’)
convolutionalUnit(2*netWidth , 1, ‘S2U2’)
additionLayer(2, ‘Name’, ‘add22’)
reluLayer(‘Name’, ‘relu22’)
convolutionalUnit(4*netWidth, 2, ‘S3U1’)
additionLayer(2, ‘Name’, ‘add31’)
reluLayer(‘Name’, ‘relu31’)
convolutionalUnit(4*netWidth, 1, ‘S3U2’)
additionLayer(2, ‘Name’, ‘add32’)
reluLayer(‘Name’, ‘relu32’)
averagePooling2dLayer(8, ‘Name’, ‘globalPool’)
fullyConnectedLayer(4, ‘Name’, ‘fcFinal’)
softmaxLayer(‘Name’, ‘softmax’)
classificationLayer(‘Name’, ‘classoutput’)
];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph, ‘reluInp’, ‘add11/in2’);
lgraph = connectLayers(lgraph, ‘relu11’, ‘add12/in2’);
skip1 = [
convolution2dLayer(1,2*netWidth, ‘Stride’, 2, ‘Name’, ‘skipConv1’)
batchNormalizationLayer(‘Name’, ‘skipBN1’)];
lgraph = addLayers(lgraph, skip1);
lgraph = connectLayers(lgraph, ‘relu12’, ‘skipConv1’);
lgraph = connectLayers(lgraph, ‘skipBN1’, ‘add21/in2’);
lgraph = connectLayers(lgraph, ‘relu21’, ‘add22/in2’);
skip2 = [
convolution2dLayer(1, 4*netWidth, ‘Stride’,2, ‘Name’, ‘skipConv2’)
batchNormalizationLayer(‘Name’,’skipBN2′)];
lgraph = addLayers(lgraph, skip2);
lgraph = connectLayers(lgraph, ‘relu22’, ‘skipConv2’);
lgraph = connectLayers(lgraph, ‘skipBN2’, ‘add31/in2’);
%add last identity connection and plot the final layer graph
lgraph = connectLayers(lgraph, ‘relu31’, ‘add32/in2’);
%training options
options = trainingOptions("sgdm", …
‘MiniBatchSize’, 128, …
‘MaxEpochs’, 1, …
‘InitialLearnRate’,1e-4);
% network training
[trainedNet1, traininfo] = trainNetwork(trainData1, lgraph, options);
And the output error is this:
% network training
[trainedNet1, traininfo] = trainNetwork(trainData1, lgraph, options);
Error using trainNetwork
The training images are of size 3024×4032×3 but the input layer expects images of size 224×224×3.
My workspace is this:
Thank You. Hope You Can Help. Hello I’m new in using pretrained networks in MATLAB for Object Detection and I was following a guide in Youtube which uses YOLO for detection. In this guide, it also used the resnet50 pretrained network which has an input layer that expects images of size (224x224x3).
Below is the code:
trainData1 = Data;
%%% Create resnet50 pretrained network
netWidth = 16;
layers = [
imageInputLayer([224 224 3], ‘Name’, ‘input’)
convolution2dLayer(3, netWidth, ‘Padding’,’same’, ‘Name’, ‘convInp’)
batchNormalizationLayer(‘Name’, ‘BNInp’)
reluLayer(‘Name’, ‘reluInp’)
convolutionalUnit(netWidth, 1, ‘S1U1’)
additionLayer(2, ‘Name’, ‘add11’)
reluLayer(‘Name’, ‘relu11’)
convolutionalUnit(netWidth, 1, ‘S1U2’)
additionLayer(2, ‘Name’, ‘add12’)
reluLayer(‘Name’, ‘relu12’)
convolutionalUnit(2*netWidth, 2, ‘S2U1’)
additionLayer(2, ‘Name’, ‘add21’)
reluLayer(‘Name’, ‘relu21’)
convolutionalUnit(2*netWidth , 1, ‘S2U2’)
additionLayer(2, ‘Name’, ‘add22’)
reluLayer(‘Name’, ‘relu22’)
convolutionalUnit(4*netWidth, 2, ‘S3U1’)
additionLayer(2, ‘Name’, ‘add31’)
reluLayer(‘Name’, ‘relu31’)
convolutionalUnit(4*netWidth, 1, ‘S3U2’)
additionLayer(2, ‘Name’, ‘add32’)
reluLayer(‘Name’, ‘relu32’)
averagePooling2dLayer(8, ‘Name’, ‘globalPool’)
fullyConnectedLayer(4, ‘Name’, ‘fcFinal’)
softmaxLayer(‘Name’, ‘softmax’)
classificationLayer(‘Name’, ‘classoutput’)
];
lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph, ‘reluInp’, ‘add11/in2’);
lgraph = connectLayers(lgraph, ‘relu11’, ‘add12/in2’);
skip1 = [
convolution2dLayer(1,2*netWidth, ‘Stride’, 2, ‘Name’, ‘skipConv1’)
batchNormalizationLayer(‘Name’, ‘skipBN1’)];
lgraph = addLayers(lgraph, skip1);
lgraph = connectLayers(lgraph, ‘relu12’, ‘skipConv1’);
lgraph = connectLayers(lgraph, ‘skipBN1’, ‘add21/in2’);
lgraph = connectLayers(lgraph, ‘relu21’, ‘add22/in2’);
skip2 = [
convolution2dLayer(1, 4*netWidth, ‘Stride’,2, ‘Name’, ‘skipConv2’)
batchNormalizationLayer(‘Name’,’skipBN2′)];
lgraph = addLayers(lgraph, skip2);
lgraph = connectLayers(lgraph, ‘relu22’, ‘skipConv2’);
lgraph = connectLayers(lgraph, ‘skipBN2’, ‘add31/in2’);
%add last identity connection and plot the final layer graph
lgraph = connectLayers(lgraph, ‘relu31’, ‘add32/in2’);
%training options
options = trainingOptions("sgdm", …
‘MiniBatchSize’, 128, …
‘MaxEpochs’, 1, …
‘InitialLearnRate’,1e-4);
% network training
[trainedNet1, traininfo] = trainNetwork(trainData1, lgraph, options);
And the output error is this:
% network training
[trainedNet1, traininfo] = trainNetwork(trainData1, lgraph, options);
Error using trainNetwork
The training images are of size 3024×4032×3 but the input layer expects images of size 224×224×3.
My workspace is this:
Thank You. Hope You Can Help. image processing, object detection, yolo, matlab, resizing, resnet50 MATLAB Answers — New Questions
How to present the content of a field in a program?
I want to present the variables and their value from a structure in a program, just for information for the users.
Let’s say:
a.a=234.5;
a.b=444;
a.s=’This is an example’;
a
if I run this code in the command window, I get the answer:
a =
struct with fields:
a: 234.5
b: 444
s: ‘This is an example’
I want to reproduce this answer and put it in a text window in my program. I could not figure out how to do that.
Thanks for any help!I want to present the variables and their value from a structure in a program, just for information for the users.
Let’s say:
a.a=234.5;
a.b=444;
a.s=’This is an example’;
a
if I run this code in the command window, I get the answer:
a =
struct with fields:
a: 234.5
b: 444
s: ‘This is an example’
I want to reproduce this answer and put it in a text window in my program. I could not figure out how to do that.
Thanks for any help! I want to present the variables and their value from a structure in a program, just for information for the users.
Let’s say:
a.a=234.5;
a.b=444;
a.s=’This is an example’;
a
if I run this code in the command window, I get the answer:
a =
struct with fields:
a: 234.5
b: 444
s: ‘This is an example’
I want to reproduce this answer and put it in a text window in my program. I could not figure out how to do that.
Thanks for any help! matlab, fields, structures MATLAB Answers — New Questions
I encountered the error ‘The MATLAB Editor requires Java.’
I encountered the error’The MATLAB Editor requires Java.’
while following the ‘Run Batch Parallel Jobs’ tutorial. I am seeking assistance with this issue.
+ Java’s version on my PC is
version -java
‘Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode’
And I have already installed the latest version of Java from Oracle.
The code I executed is shown below:
mywave.m
edit mywave
for i = 1:1024
A(i) = sin(i*2*pi/1024);
end
Untitled.m
job = batch(‘mywave’)
wait(job)
load(job)
Error message in Command window is shown below:
Error using parallel.Job/load (line 36)
Error encountered while running the batch job. The error was:
Error using edit (line 73)
The MATLAB Editor requires Java.
Error in mywave (line 1)
The same issue occurred in both (R2024a) and (R2023a).I encountered the error’The MATLAB Editor requires Java.’
while following the ‘Run Batch Parallel Jobs’ tutorial. I am seeking assistance with this issue.
+ Java’s version on my PC is
version -java
‘Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode’
And I have already installed the latest version of Java from Oracle.
The code I executed is shown below:
mywave.m
edit mywave
for i = 1:1024
A(i) = sin(i*2*pi/1024);
end
Untitled.m
job = batch(‘mywave’)
wait(job)
load(job)
Error message in Command window is shown below:
Error using parallel.Job/load (line 36)
Error encountered while running the batch job. The error was:
Error using edit (line 73)
The MATLAB Editor requires Java.
Error in mywave (line 1)
The same issue occurred in both (R2024a) and (R2023a). I encountered the error’The MATLAB Editor requires Java.’
while following the ‘Run Batch Parallel Jobs’ tutorial. I am seeking assistance with this issue.
+ Java’s version on my PC is
version -java
‘Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode’
And I have already installed the latest version of Java from Oracle.
The code I executed is shown below:
mywave.m
edit mywave
for i = 1:1024
A(i) = sin(i*2*pi/1024);
end
Untitled.m
job = batch(‘mywave’)
wait(job)
load(job)
Error message in Command window is shown below:
Error using parallel.Job/load (line 36)
Error encountered while running the batch job. The error was:
Error using edit (line 73)
The MATLAB Editor requires Java.
Error in mywave (line 1)
The same issue occurred in both (R2024a) and (R2023a). java MATLAB Answers — New Questions
How to do setup data queue handling between app designer and parallel thread?
Hello community
I want to use the Parallel Pool Box in App Designer to run a parallel thread and pass information between the two entitiies.
Imagine the following use case: You want to start, pause and abort i.e. a sequence of measurements from the GUI
In case the start is activated the start button changes to pause button and starts in parallel the measurement sequence.
In case the executions is paused, the current step of the sequence is allowed to be finished.
In case of abort the measurement shall be stopped immediatly and the instruments gracefully turned off.
I tried to represent this in a workflow (shown at end of post- file follows as soon as upload works again). And did setup a simplified .mlapp first trying to start a parallel thread queueing information and the main code fetching that information and diplaying it in a text area. But in that form I cannot save it as .mlapp file. From what I’ve read so far in the forum (see list below) it seems to be an issue of handing over the app object to the parallel process. But I don’t understand what I am doing wrong and thus think I missed an important part of the data queue handling. I would be glad for any hint/information/support to fix this issue and learn from that mistake.
Further information I checked prior to set up .mlapp:
https://ch.mathworks.com/matlabcentral/answers/867683-how-to-use-threads-in-matlab-app-designer/
https://ch.mathworks.com/matlabcentral/answers/1413247-threading-in-matlab-gui-callbacks
https://ch.mathworks.com/matlabcentral/answers/2164600-integrating-parallel-computing-with-app-designer-for-real-time-ui-updates
– https://www.mathworks.com/matlabcentral/answers/366576-will-there-be-a-support-of-the-parallel-toolbox-in-matlab-app-designer#comment_720548
https://ch.mathworks.com/help/parallel-computing/parallel.pool.dataqueue.html
https://ch.mathworks.com/help/parallel-computing/parpool.html
https://ch.mathworks.com/help/parallel-computing/parallel.pool.pollabledataqueue.html
https://ch.mathworks.com/help/parallel-computing/receive-communications-on-workers.html
https://in.mathworks.com/matlabcentral/answers/1726505-proper-use-of-dataqueue-and-pollabledataqueue-inside-of-app-designer-class
Example code which can not be saved as .mlapp
classdef ExampleWorkflowAbortAsyn < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Abort2Button matlab.ui.control.StateButton
TextArea matlab.ui.control.TextArea
AbortButton matlab.ui.control.Button
StartButton matlab.ui.control.Button
end
properties (Access = public)
TCindex % Description
isPassed = false;
asycnWorker
dataQueue
clientQueue
helperClientQueue
end
methods (Static)
function receiveDataOnClient(data)
disp(data);
drawnow limitrate;
end
end
methods (Access = public)
function testExecutionMaster(app)
while strcmp(app.StartButton.Text, ‘Pause’)
app.isPassed = false;
updateUILog(app,sprintf(‘TC %i’, app.TCindex));
app.TCindex = app.TCindex + 1;
updateUILog(app,sprintf(‘tPrepare measurement…’));
pause(1)
updateUILog(app,sprintf(‘tExecute measurement…’));
pause(1)
updateUILog(app,sprintf(‘tAnalyze Measurement…’));
pause(1)
updateUILog(app,sprintf(‘t Test passed :)’));
app.isPassed = true;
end
end
function abortMeasurementAction(app)
% nice to have: pop up with abort error and instructions
updateUILog(app,’User triggerd abort starts’);
updateUILog(app,sprintf(‘tAll devices off’));
end
function updateUILog(app,message)
textArray = app.TextArea.Value;
textArray{end+1} = message;
app.TextArea.Value = textArray;
scroll(app.TextArea, ‘bottom’)
% createDiaryEntry(app, message)
end
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: StartButton
function EnterTestState(app, event)
switch app.StartButton.Text
case ‘Start’
app.StartButton.Text = ‘Pause’;
app.TCindex = 1;
asycnWorker = parpool(‘Threads’,1);
clientQueue = parallel.pool.DataQueue;
afterEach(clientQueue,@(data) app.receiveDataOnClient(data));
helperClientQueue = parallel.pool.PollableDataQueue;
temp = app.StartButton.Text;
wkrF = parallel.FevalFuture;
wkrF = parfeval(@testExecutionWorker,0,temp);
wkrQueue = poll(helperClientQueue,inf);
send(wkrQueue.Queue,"Start generating data");
case ‘Pause’
app.StartButton.Text = ‘Resume’;
updateUILog(app,’Test execution enters pause state’)
while ~app.isPassed
pause(0.2)
end
updateUILog(app,sprintf(‘Test execution paused at %i’, app.TCindex));
case ‘Resume’
app.StartButton.Text = ‘Pause’;
updateUILog(app,’Resume test execution’);
testExecutionMaster(app)
end
updateUILog(app,"End of EnterTestStateFunction")
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = ‘MATLAB App’;
% Create StartButton
app.StartButton = uibutton(app.UIFigure, ‘push’);
app.StartButton.ButtonPushedFcn = createCallbackFcn(app, @EnterTestState, true);
app.StartButton.Position = [422 321 138 45];
app.StartButton.Text = ‘Start’;
% Create AbortButton
app.AbortButton = uibutton(app.UIFigure, ‘push’);
app.AbortButton.Position = [422 249 138 41];
app.AbortButton.Text = ‘Abort’;
% Create TextArea
app.TextArea = uitextarea(app.UIFigure);
app.TextArea.Editable = ‘off’;
app.TextArea.Position = [60 28 475 168];
% Create Abort2Button
app.Abort2Button = uibutton(app.UIFigure, ‘state’);
app.Abort2Button.Text = ‘Abort2’;
app.Abort2Button.Position = [129 289 186 54];
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = ExampleWorkflowAbortAsyn
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
endHello community
I want to use the Parallel Pool Box in App Designer to run a parallel thread and pass information between the two entitiies.
Imagine the following use case: You want to start, pause and abort i.e. a sequence of measurements from the GUI
In case the start is activated the start button changes to pause button and starts in parallel the measurement sequence.
In case the executions is paused, the current step of the sequence is allowed to be finished.
In case of abort the measurement shall be stopped immediatly and the instruments gracefully turned off.
I tried to represent this in a workflow (shown at end of post- file follows as soon as upload works again). And did setup a simplified .mlapp first trying to start a parallel thread queueing information and the main code fetching that information and diplaying it in a text area. But in that form I cannot save it as .mlapp file. From what I’ve read so far in the forum (see list below) it seems to be an issue of handing over the app object to the parallel process. But I don’t understand what I am doing wrong and thus think I missed an important part of the data queue handling. I would be glad for any hint/information/support to fix this issue and learn from that mistake.
Further information I checked prior to set up .mlapp:
https://ch.mathworks.com/matlabcentral/answers/867683-how-to-use-threads-in-matlab-app-designer/
https://ch.mathworks.com/matlabcentral/answers/1413247-threading-in-matlab-gui-callbacks
https://ch.mathworks.com/matlabcentral/answers/2164600-integrating-parallel-computing-with-app-designer-for-real-time-ui-updates
– https://www.mathworks.com/matlabcentral/answers/366576-will-there-be-a-support-of-the-parallel-toolbox-in-matlab-app-designer#comment_720548
https://ch.mathworks.com/help/parallel-computing/parallel.pool.dataqueue.html
https://ch.mathworks.com/help/parallel-computing/parpool.html
https://ch.mathworks.com/help/parallel-computing/parallel.pool.pollabledataqueue.html
https://ch.mathworks.com/help/parallel-computing/receive-communications-on-workers.html
https://in.mathworks.com/matlabcentral/answers/1726505-proper-use-of-dataqueue-and-pollabledataqueue-inside-of-app-designer-class
Example code which can not be saved as .mlapp
classdef ExampleWorkflowAbortAsyn < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Abort2Button matlab.ui.control.StateButton
TextArea matlab.ui.control.TextArea
AbortButton matlab.ui.control.Button
StartButton matlab.ui.control.Button
end
properties (Access = public)
TCindex % Description
isPassed = false;
asycnWorker
dataQueue
clientQueue
helperClientQueue
end
methods (Static)
function receiveDataOnClient(data)
disp(data);
drawnow limitrate;
end
end
methods (Access = public)
function testExecutionMaster(app)
while strcmp(app.StartButton.Text, ‘Pause’)
app.isPassed = false;
updateUILog(app,sprintf(‘TC %i’, app.TCindex));
app.TCindex = app.TCindex + 1;
updateUILog(app,sprintf(‘tPrepare measurement…’));
pause(1)
updateUILog(app,sprintf(‘tExecute measurement…’));
pause(1)
updateUILog(app,sprintf(‘tAnalyze Measurement…’));
pause(1)
updateUILog(app,sprintf(‘t Test passed :)’));
app.isPassed = true;
end
end
function abortMeasurementAction(app)
% nice to have: pop up with abort error and instructions
updateUILog(app,’User triggerd abort starts’);
updateUILog(app,sprintf(‘tAll devices off’));
end
function updateUILog(app,message)
textArray = app.TextArea.Value;
textArray{end+1} = message;
app.TextArea.Value = textArray;
scroll(app.TextArea, ‘bottom’)
% createDiaryEntry(app, message)
end
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: StartButton
function EnterTestState(app, event)
switch app.StartButton.Text
case ‘Start’
app.StartButton.Text = ‘Pause’;
app.TCindex = 1;
asycnWorker = parpool(‘Threads’,1);
clientQueue = parallel.pool.DataQueue;
afterEach(clientQueue,@(data) app.receiveDataOnClient(data));
helperClientQueue = parallel.pool.PollableDataQueue;
temp = app.StartButton.Text;
wkrF = parallel.FevalFuture;
wkrF = parfeval(@testExecutionWorker,0,temp);
wkrQueue = poll(helperClientQueue,inf);
send(wkrQueue.Queue,"Start generating data");
case ‘Pause’
app.StartButton.Text = ‘Resume’;
updateUILog(app,’Test execution enters pause state’)
while ~app.isPassed
pause(0.2)
end
updateUILog(app,sprintf(‘Test execution paused at %i’, app.TCindex));
case ‘Resume’
app.StartButton.Text = ‘Pause’;
updateUILog(app,’Resume test execution’);
testExecutionMaster(app)
end
updateUILog(app,"End of EnterTestStateFunction")
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = ‘MATLAB App’;
% Create StartButton
app.StartButton = uibutton(app.UIFigure, ‘push’);
app.StartButton.ButtonPushedFcn = createCallbackFcn(app, @EnterTestState, true);
app.StartButton.Position = [422 321 138 45];
app.StartButton.Text = ‘Start’;
% Create AbortButton
app.AbortButton = uibutton(app.UIFigure, ‘push’);
app.AbortButton.Position = [422 249 138 41];
app.AbortButton.Text = ‘Abort’;
% Create TextArea
app.TextArea = uitextarea(app.UIFigure);
app.TextArea.Editable = ‘off’;
app.TextArea.Position = [60 28 475 168];
% Create Abort2Button
app.Abort2Button = uibutton(app.UIFigure, ‘state’);
app.Abort2Button.Text = ‘Abort2’;
app.Abort2Button.Position = [129 289 186 54];
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = ExampleWorkflowAbortAsyn
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end Hello community
I want to use the Parallel Pool Box in App Designer to run a parallel thread and pass information between the two entitiies.
Imagine the following use case: You want to start, pause and abort i.e. a sequence of measurements from the GUI
In case the start is activated the start button changes to pause button and starts in parallel the measurement sequence.
In case the executions is paused, the current step of the sequence is allowed to be finished.
In case of abort the measurement shall be stopped immediatly and the instruments gracefully turned off.
I tried to represent this in a workflow (shown at end of post- file follows as soon as upload works again). And did setup a simplified .mlapp first trying to start a parallel thread queueing information and the main code fetching that information and diplaying it in a text area. But in that form I cannot save it as .mlapp file. From what I’ve read so far in the forum (see list below) it seems to be an issue of handing over the app object to the parallel process. But I don’t understand what I am doing wrong and thus think I missed an important part of the data queue handling. I would be glad for any hint/information/support to fix this issue and learn from that mistake.
Further information I checked prior to set up .mlapp:
https://ch.mathworks.com/matlabcentral/answers/867683-how-to-use-threads-in-matlab-app-designer/
https://ch.mathworks.com/matlabcentral/answers/1413247-threading-in-matlab-gui-callbacks
https://ch.mathworks.com/matlabcentral/answers/2164600-integrating-parallel-computing-with-app-designer-for-real-time-ui-updates
– https://www.mathworks.com/matlabcentral/answers/366576-will-there-be-a-support-of-the-parallel-toolbox-in-matlab-app-designer#comment_720548
https://ch.mathworks.com/help/parallel-computing/parallel.pool.dataqueue.html
https://ch.mathworks.com/help/parallel-computing/parpool.html
https://ch.mathworks.com/help/parallel-computing/parallel.pool.pollabledataqueue.html
https://ch.mathworks.com/help/parallel-computing/receive-communications-on-workers.html
https://in.mathworks.com/matlabcentral/answers/1726505-proper-use-of-dataqueue-and-pollabledataqueue-inside-of-app-designer-class
Example code which can not be saved as .mlapp
classdef ExampleWorkflowAbortAsyn < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Abort2Button matlab.ui.control.StateButton
TextArea matlab.ui.control.TextArea
AbortButton matlab.ui.control.Button
StartButton matlab.ui.control.Button
end
properties (Access = public)
TCindex % Description
isPassed = false;
asycnWorker
dataQueue
clientQueue
helperClientQueue
end
methods (Static)
function receiveDataOnClient(data)
disp(data);
drawnow limitrate;
end
end
methods (Access = public)
function testExecutionMaster(app)
while strcmp(app.StartButton.Text, ‘Pause’)
app.isPassed = false;
updateUILog(app,sprintf(‘TC %i’, app.TCindex));
app.TCindex = app.TCindex + 1;
updateUILog(app,sprintf(‘tPrepare measurement…’));
pause(1)
updateUILog(app,sprintf(‘tExecute measurement…’));
pause(1)
updateUILog(app,sprintf(‘tAnalyze Measurement…’));
pause(1)
updateUILog(app,sprintf(‘t Test passed :)’));
app.isPassed = true;
end
end
function abortMeasurementAction(app)
% nice to have: pop up with abort error and instructions
updateUILog(app,’User triggerd abort starts’);
updateUILog(app,sprintf(‘tAll devices off’));
end
function updateUILog(app,message)
textArray = app.TextArea.Value;
textArray{end+1} = message;
app.TextArea.Value = textArray;
scroll(app.TextArea, ‘bottom’)
% createDiaryEntry(app, message)
end
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: StartButton
function EnterTestState(app, event)
switch app.StartButton.Text
case ‘Start’
app.StartButton.Text = ‘Pause’;
app.TCindex = 1;
asycnWorker = parpool(‘Threads’,1);
clientQueue = parallel.pool.DataQueue;
afterEach(clientQueue,@(data) app.receiveDataOnClient(data));
helperClientQueue = parallel.pool.PollableDataQueue;
temp = app.StartButton.Text;
wkrF = parallel.FevalFuture;
wkrF = parfeval(@testExecutionWorker,0,temp);
wkrQueue = poll(helperClientQueue,inf);
send(wkrQueue.Queue,"Start generating data");
case ‘Pause’
app.StartButton.Text = ‘Resume’;
updateUILog(app,’Test execution enters pause state’)
while ~app.isPassed
pause(0.2)
end
updateUILog(app,sprintf(‘Test execution paused at %i’, app.TCindex));
case ‘Resume’
app.StartButton.Text = ‘Pause’;
updateUILog(app,’Resume test execution’);
testExecutionMaster(app)
end
updateUILog(app,"End of EnterTestStateFunction")
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure(‘Visible’, ‘off’);
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = ‘MATLAB App’;
% Create StartButton
app.StartButton = uibutton(app.UIFigure, ‘push’);
app.StartButton.ButtonPushedFcn = createCallbackFcn(app, @EnterTestState, true);
app.StartButton.Position = [422 321 138 45];
app.StartButton.Text = ‘Start’;
% Create AbortButton
app.AbortButton = uibutton(app.UIFigure, ‘push’);
app.AbortButton.Position = [422 249 138 41];
app.AbortButton.Text = ‘Abort’;
% Create TextArea
app.TextArea = uitextarea(app.UIFigure);
app.TextArea.Editable = ‘off’;
app.TextArea.Position = [60 28 475 168];
% Create Abort2Button
app.Abort2Button = uibutton(app.UIFigure, ‘state’);
app.Abort2Button.Text = ‘Abort2’;
app.Abort2Button.Position = [129 289 186 54];
% Show the figure after all components are created
app.UIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = ExampleWorkflowAbortAsyn
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end appdesigner, parallel computing toolbox, dataqueue, asynchronous MATLAB Answers — New Questions
How to modify the font size of files and variable interface in matlab 2025a.
How to modify the font size of files and variable interface in matlab 2025a.?
I can’t find this option.How to modify the font size of files and variable interface in matlab 2025a.?
I can’t find this option. How to modify the font size of files and variable interface in matlab 2025a.?
I can’t find this option. matlab 2025a MATLAB Answers — New Questions
Simscape missing in Simulink Library
I have Matlab 2021B installed on my pc. But I cannot find Simscape Electrical in the library of Simulink . How can I install it using the same license, kindly elaborate in detailsI have Matlab 2021B installed on my pc. But I cannot find Simscape Electrical in the library of Simulink . How can I install it using the same license, kindly elaborate in details I have Matlab 2021B installed on my pc. But I cannot find Simscape Electrical in the library of Simulink . How can I install it using the same license, kindly elaborate in details simscape MATLAB Answers — New Questions
stftLayer error: “Size of input in T dimension must be greater than or equal to window length” despite correct input shape
Hi everyone,
I’m encountering a confusing issue when using the stftLayer in MATLAB’s Deep Learning Toolbox. I’m trying to pass a dlarray signal to an stftLayer inside a dlnetwork. The input signal has size:
size(signal) – [1 24 2401]
dims(signal) – ‘CBT’
The stfftLayer configuration is:
winLength = 256;
overlap = 128;
fftLength = 256;
stft_net = [sequenceInputLayer(size(signal,1))
stftLayer("Window",winLength,"FFTLength",fftLength,"OverlapLength",overlap,"Name","stft")];
stftNet = dlnetwork(stft_net);
However, when I am trying to use this model, I am receiving the following error:
Error using stftLayer/validateProperties (line 238)
Window length must be greater than one sample.
Error in stftLayer (line 166)
this = validateProperties(this);
^^^^^^^^^^^^^^^^^^^^^^^^
The signal properties are shown below for further clarity
K>> size(signal)
ans =
1 24 2401
K>> dims(signal)
ans =
‘CBT’
What could be causing the stftLayer to misinterpret the time dimension and throw the error, even when T is clearly larger than the window length? Any insights would be much appreciated.Hi everyone,
I’m encountering a confusing issue when using the stftLayer in MATLAB’s Deep Learning Toolbox. I’m trying to pass a dlarray signal to an stftLayer inside a dlnetwork. The input signal has size:
size(signal) – [1 24 2401]
dims(signal) – ‘CBT’
The stfftLayer configuration is:
winLength = 256;
overlap = 128;
fftLength = 256;
stft_net = [sequenceInputLayer(size(signal,1))
stftLayer("Window",winLength,"FFTLength",fftLength,"OverlapLength",overlap,"Name","stft")];
stftNet = dlnetwork(stft_net);
However, when I am trying to use this model, I am receiving the following error:
Error using stftLayer/validateProperties (line 238)
Window length must be greater than one sample.
Error in stftLayer (line 166)
this = validateProperties(this);
^^^^^^^^^^^^^^^^^^^^^^^^
The signal properties are shown below for further clarity
K>> size(signal)
ans =
1 24 2401
K>> dims(signal)
ans =
‘CBT’
What could be causing the stftLayer to misinterpret the time dimension and throw the error, even when T is clearly larger than the window length? Any insights would be much appreciated. Hi everyone,
I’m encountering a confusing issue when using the stftLayer in MATLAB’s Deep Learning Toolbox. I’m trying to pass a dlarray signal to an stftLayer inside a dlnetwork. The input signal has size:
size(signal) – [1 24 2401]
dims(signal) – ‘CBT’
The stfftLayer configuration is:
winLength = 256;
overlap = 128;
fftLength = 256;
stft_net = [sequenceInputLayer(size(signal,1))
stftLayer("Window",winLength,"FFTLength",fftLength,"OverlapLength",overlap,"Name","stft")];
stftNet = dlnetwork(stft_net);
However, when I am trying to use this model, I am receiving the following error:
Error using stftLayer/validateProperties (line 238)
Window length must be greater than one sample.
Error in stftLayer (line 166)
this = validateProperties(this);
^^^^^^^^^^^^^^^^^^^^^^^^
The signal properties are shown below for further clarity
K>> size(signal)
ans =
1 24 2401
K>> dims(signal)
ans =
‘CBT’
What could be causing the stftLayer to misinterpret the time dimension and throw the error, even when T is clearly larger than the window length? Any insights would be much appreciated. stftlayer, deep learning, signal processing MATLAB Answers — New Questions
Version 2025a does not open the editor.
How can I make version 2025a read the session history and open the editor with the previously opened files?
After installation, a new prefdir is created for 2025, and all files from the 2024 version directory are transferred to it — including MATLABDesktop.xml, MATLAB_Editor_State.xml, History.xml, etc. However, the editor does not open.
Ctrl-Shift-0 doesn’t work either.
I tried deleting the 2025 version’s prefdir, but that didn’t change the situation.
What should I do? I’d prefer not to open dozens of files manually.How can I make version 2025a read the session history and open the editor with the previously opened files?
After installation, a new prefdir is created for 2025, and all files from the 2024 version directory are transferred to it — including MATLABDesktop.xml, MATLAB_Editor_State.xml, History.xml, etc. However, the editor does not open.
Ctrl-Shift-0 doesn’t work either.
I tried deleting the 2025 version’s prefdir, but that didn’t change the situation.
What should I do? I’d prefer not to open dozens of files manually. How can I make version 2025a read the session history and open the editor with the previously opened files?
After installation, a new prefdir is created for 2025, and all files from the 2024 version directory are transferred to it — including MATLABDesktop.xml, MATLAB_Editor_State.xml, History.xml, etc. However, the editor does not open.
Ctrl-Shift-0 doesn’t work either.
I tried deleting the 2025 version’s prefdir, but that didn’t change the situation.
What should I do? I’d prefer not to open dozens of files manually. 2025a editor MATLAB Answers — New Questions
Step wise execution of “Transmit and Receive Tone Using AMD RFSoC Device” for ZCU208 RFSoC Board
Hi,
Kindly, provide step by step wise execution of "Transmit and Receive Tone Using AMD RFSoC Device" for ZCU208 RFSoC Board bcoz ,I have just started using RFSoC & MATLAB recently and have read out ADC out via System Generator(Simulink).Hi,
Kindly, provide step by step wise execution of "Transmit and Receive Tone Using AMD RFSoC Device" for ZCU208 RFSoC Board bcoz ,I have just started using RFSoC & MATLAB recently and have read out ADC out via System Generator(Simulink). Hi,
Kindly, provide step by step wise execution of "Transmit and Receive Tone Using AMD RFSoC Device" for ZCU208 RFSoC Board bcoz ,I have just started using RFSoC & MATLAB recently and have read out ADC out via System Generator(Simulink). transmit and receive tone using amd rfsoc device MATLAB Answers — New Questions
Microsoft Launches the Copilot Interaction Export API
aiInteractionHistory Graph API Available in June 2025
Microsoft 365 message center notification MC1080682 (22 May 2025, Microsoft 365 Roadmap item 491631) announces that the new Microsoft 365 Copilot Interaction Export API (aka, the aiInteractionHistory API) will roll out in June 2025. This is the same API that I covered in a Practical365.com article last December and the documentation still says that the API is available through the Graph beta endpoint. Perhaps the intention is to move the API to the V1.0 (production) endpoint when it’s officially released.
I don’t see much change in how the API works or the retrieved data since I last looked at it. A welcome change is that it is now possible to fetch a maximum of 100 records per request rather then ten. Fetching ten interaction records at a time made the API very slow. Although faster than before, the API is still slow, especially for an API designed to allow third-party apps and ISVs “to export Copilot user interaction data for processing in their security and compliance (S+C) applications.”
Other audit APIs support fetching up to a thousand records at a time. Maybe a V1.0 version of the API will support a higher value. Details of how the API works and an example script can be found in the original article.
Licenses and Permissions
The AiEnterpriseInteraction.Read.All Graph permission needed to access interaction data is not available as a delegated permission, meaning that the only way to access the data is through an app (including app-only interactive Microsoft Graph PowerShell SDK sessions). Weirdly, accounts used to run apps using the API to fetch interaction records must have a Microsoft 365 Copilot license.
What the aiInteractionHistory API Captures
According to Microsoft, the API “captures the user prompts and Copilot responses in Copilot private interactions chat and provides insights into the resources Copilot has accessed to generate the response.” This statement does not mean that the data lays bare the details of Copilot interactions. Some of the information needs to be mined and interpreted to make sense. For instance, here are the details of an interaction record:
Name Value ---- ----- locale en-us body {[content, [AutoGenerated]undefined<attachment id="fd3a9044-309c-4ec9-a568-676f1d521f24"></attachment><attachment id="01TAGX3U2ESA5P3HBQZFHKK2DHN… from {[@odata.type, #microsoft.graph.chatMessageFromIdentitySet], [user, System.Collections.Hashtable], [application, ], [device, ]} appClass IPM.SkypeTeams.Message.Copilot.Word attachments {02 Managing Identities.docx, unknown-file-name} contexts {02 Managing Identities.docx, unknown-file-name} createdDateTime 25/04/2025 09:27:05 conversationType appchat interactionType userPrompt mentions {} links {} sessionId 19:[email protected] id 1745573225046 requestId GTbr3lBouCMpcP7L1qVv8Q.20.1.1.1.4 etag 1745573225046
The appClass property tells us what Copilot app the interaction is for. In this case, it’s Copilot for Word. The attachments property tells us if any reference files are used. One is mentioned here, and given that the body property mentions AutoGenerated, we can conclude that this interaction occurred when Copilot for Word generated an automatic summary for a document.
The interactionType tells us that this record is for a user prompt. Responses from Copilot have aiResponse in the interactionType property. User prompts that aren’t for automatic summaries have the text of the prompt in the body property. For example:
Name Value ---- ----- content What functionality isn't available with a Microsoft 365 retention policy contentType text
aiInteractionHistory API requests require the identifier for a user account and the response is the records for that user. Details of the user are in the from property, but you’ll have to navigate to from.user.id to see the identifier for the user. A DisplayName property is available in the from structure but doesn’t hold the display name of the user.
Assuming that a third-party application wanted to retrieve the ai interaction history records and process the records for its own purposes, it’s obvious from this brief discussion that the application has some work to do to interpret the raw data to make it useful for compliance investigations or other purposes. The script published with the December article referenced above shows how to approach the task, which is like the parsing of audit records to extract useful content. Figure 1 shows the kind of data that can be extracted from the aiInteractionHistory API records.

The Many Sources of Information About Copilot Interactions
It’s hard to know how useful the aiInteractionHistory API will turn out to be. Other sources of information can be mined to discover how people use Copilot, including usage data, audit records, and the compliance records held in user mailboxes. I guess it all depends on what you’re looking for.
Modifying Simscape Initial Conditions
We receive a simscape plant model together with a .mat file containing the initial conditions.
We want to place that simscape model into a subsystem, connect it to a controller model, and save the combined model as a different model name.
The Initial Conditions variable is a structure array with .signals.blockName and .signals.stateName fields containing the full path of the simscape blocks. For example
>> disp(InitialConditions.signals(10).blockName)
Architecture_Delivery2/C11/Bulk Heater
and
>> disp(MissionProfile_InitialConditions.signals(10).stateName)
Architecture_Delivery2.C11.Bulk_Heater.BH_3_.p_I
All well and good – I’ve written a simple function to strrep() from the original model/path names to the new model/path names. This works most of the time. However occasionally I see a stateName like this:
>> disp(InitialConditions.signals(2).stateName)
Architecture_Delivery2.Simulink_PS_Converter14.outputFiltered_3445558726_0
and when I save the model, the numbers at the end can change (sometimes, not always). This means that the model fails to initialise as it can’t find the correct stateName.
Unable to load the specified initial state for model ‘Combined_Plant_Controller’. BlockName/BlockPath of the element at index 2 in the initial state is invalid
Note that this error is incorrect – it’s not the Block Name/Path that’s incorrect but the State Name/Path.
So, my questions are;
Why do some blocks have seemingly random numbers appended to the stateName and others don’t?
Is there a way to programmatically examine a model to find out what number has been given to a block’s stateName so that I can update the initial conditions variable correctly?We receive a simscape plant model together with a .mat file containing the initial conditions.
We want to place that simscape model into a subsystem, connect it to a controller model, and save the combined model as a different model name.
The Initial Conditions variable is a structure array with .signals.blockName and .signals.stateName fields containing the full path of the simscape blocks. For example
>> disp(InitialConditions.signals(10).blockName)
Architecture_Delivery2/C11/Bulk Heater
and
>> disp(MissionProfile_InitialConditions.signals(10).stateName)
Architecture_Delivery2.C11.Bulk_Heater.BH_3_.p_I
All well and good – I’ve written a simple function to strrep() from the original model/path names to the new model/path names. This works most of the time. However occasionally I see a stateName like this:
>> disp(InitialConditions.signals(2).stateName)
Architecture_Delivery2.Simulink_PS_Converter14.outputFiltered_3445558726_0
and when I save the model, the numbers at the end can change (sometimes, not always). This means that the model fails to initialise as it can’t find the correct stateName.
Unable to load the specified initial state for model ‘Combined_Plant_Controller’. BlockName/BlockPath of the element at index 2 in the initial state is invalid
Note that this error is incorrect – it’s not the Block Name/Path that’s incorrect but the State Name/Path.
So, my questions are;
Why do some blocks have seemingly random numbers appended to the stateName and others don’t?
Is there a way to programmatically examine a model to find out what number has been given to a block’s stateName so that I can update the initial conditions variable correctly? We receive a simscape plant model together with a .mat file containing the initial conditions.
We want to place that simscape model into a subsystem, connect it to a controller model, and save the combined model as a different model name.
The Initial Conditions variable is a structure array with .signals.blockName and .signals.stateName fields containing the full path of the simscape blocks. For example
>> disp(InitialConditions.signals(10).blockName)
Architecture_Delivery2/C11/Bulk Heater
and
>> disp(MissionProfile_InitialConditions.signals(10).stateName)
Architecture_Delivery2.C11.Bulk_Heater.BH_3_.p_I
All well and good – I’ve written a simple function to strrep() from the original model/path names to the new model/path names. This works most of the time. However occasionally I see a stateName like this:
>> disp(InitialConditions.signals(2).stateName)
Architecture_Delivery2.Simulink_PS_Converter14.outputFiltered_3445558726_0
and when I save the model, the numbers at the end can change (sometimes, not always). This means that the model fails to initialise as it can’t find the correct stateName.
Unable to load the specified initial state for model ‘Combined_Plant_Controller’. BlockName/BlockPath of the element at index 2 in the initial state is invalid
Note that this error is incorrect – it’s not the Block Name/Path that’s incorrect but the State Name/Path.
So, my questions are;
Why do some blocks have seemingly random numbers appended to the stateName and others don’t?
Is there a way to programmatically examine a model to find out what number has been given to a block’s stateName so that I can update the initial conditions variable correctly? simscape, initialization MATLAB Answers — New Questions
How do I use fprintf to show the entire array in one ouput statement
>>
A = [-4 2 -7 6 8; 4 -5 8 -1 0; 0 -4 3 1 10; -8 7 -10 5 -2];
[rows cols] = size(A);
Z = zeros(size(A));
for x = 1:1:rows
for y = 1:1:cols
if A(x,y) <= 4
Z(x,y) = A(x,y);
end
end
end
fprintf(‘%in’,Z);
My ouput statement I am getting is
-4
4
0
-8
2
-5
-4
0
-7
0
3
-10
0
-1
1
0
0
0
0
-2
Instead of
-4 2 -7 0 0
4 -5 0 -1 0
0 -4 3 1 0
-8 0 -10 0 -2>>
A = [-4 2 -7 6 8; 4 -5 8 -1 0; 0 -4 3 1 10; -8 7 -10 5 -2];
[rows cols] = size(A);
Z = zeros(size(A));
for x = 1:1:rows
for y = 1:1:cols
if A(x,y) <= 4
Z(x,y) = A(x,y);
end
end
end
fprintf(‘%in’,Z);
My ouput statement I am getting is
-4
4
0
-8
2
-5
-4
0
-7
0
3
-10
0
-1
1
0
0
0
0
-2
Instead of
-4 2 -7 0 0
4 -5 0 -1 0
0 -4 3 1 0
-8 0 -10 0 -2 >>
A = [-4 2 -7 6 8; 4 -5 8 -1 0; 0 -4 3 1 10; -8 7 -10 5 -2];
[rows cols] = size(A);
Z = zeros(size(A));
for x = 1:1:rows
for y = 1:1:cols
if A(x,y) <= 4
Z(x,y) = A(x,y);
end
end
end
fprintf(‘%in’,Z);
My ouput statement I am getting is
-4
4
0
-8
2
-5
-4
0
-7
0
3
-10
0
-1
1
0
0
0
0
-2
Instead of
-4 2 -7 0 0
4 -5 0 -1 0
0 -4 3 1 0
-8 0 -10 0 -2 array, fprintf array, matrix, matrix array, fprintf matrix MATLAB Answers — New Questions
Error creating an FMU from a “Neural State Space Model” block
We are not able to create an FMU from from a "Neural State Space Model" block. The error that appears is:
Error:Invalid "()" reference for the "IDNEURALSTATESPACE" model.
We can run the block in Simulink perfectly but when we click also "Refresh" in the FMU settings, this error appears.
We do not have any problem for example creating an FMU with "Stateful Predict" block.We are not able to create an FMU from from a "Neural State Space Model" block. The error that appears is:
Error:Invalid "()" reference for the "IDNEURALSTATESPACE" model.
We can run the block in Simulink perfectly but when we click also "Refresh" in the FMU settings, this error appears.
We do not have any problem for example creating an FMU with "Stateful Predict" block. We are not able to create an FMU from from a "Neural State Space Model" block. The error that appears is:
Error:Invalid "()" reference for the "IDNEURALSTATESPACE" model.
We can run the block in Simulink perfectly but when we click also "Refresh" in the FMU settings, this error appears.
We do not have any problem for example creating an FMU with "Stateful Predict" block. fmu, neural network MATLAB Answers — New Questions
Why am I getting an error installing MATLAB on Ubuntu 24.04
I have just tried to download MATLAB onto Ubuntu 24.04 and it is not working.
When I run ./install within matlab_R2024a_Linux, this is the output:
terminate called after throwing an instance of ‘std::runtime_error’
what(): Failed to launch web window with error: Unable to launch the MATLABWindow application. The exit code was: 1
Aborted (core dumped)
When I then run ./bin/glnxa64/MATLABWindow , this is the output:
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /lib/x86_64-linux-gnu/libgallium-24.2.1 – kisak-mesa PPA.so)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `CXXABI_1.3.13′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.30′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.30′ not found (required by /lib/x86_64-linux-gnu/libicuuc.so.74)
I have tried reading through these guides:
https://www.mathworks.com/matlabcentral/answers/2018166-what-dependencies-are-needed-to-install-matlab-on-minimal-or-core-linux-installations
https://www.mathworks.com/matlabcentral/answers/540707-why-does-matlab-fail-to-install-with-a-std-runtime_error-what-unable-to-launch-the-matlabwind
I have tried other solutions on Stack Over flow and nothing has worked.I have just tried to download MATLAB onto Ubuntu 24.04 and it is not working.
When I run ./install within matlab_R2024a_Linux, this is the output:
terminate called after throwing an instance of ‘std::runtime_error’
what(): Failed to launch web window with error: Unable to launch the MATLABWindow application. The exit code was: 1
Aborted (core dumped)
When I then run ./bin/glnxa64/MATLABWindow , this is the output:
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /lib/x86_64-linux-gnu/libgallium-24.2.1 – kisak-mesa PPA.so)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `CXXABI_1.3.13′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.30′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.30′ not found (required by /lib/x86_64-linux-gnu/libicuuc.so.74)
I have tried reading through these guides:
https://www.mathworks.com/matlabcentral/answers/2018166-what-dependencies-are-needed-to-install-matlab-on-minimal-or-core-linux-installations
https://www.mathworks.com/matlabcentral/answers/540707-why-does-matlab-fail-to-install-with-a-std-runtime_error-what-unable-to-launch-the-matlabwind
I have tried other solutions on Stack Over flow and nothing has worked. I have just tried to download MATLAB onto Ubuntu 24.04 and it is not working.
When I run ./install within matlab_R2024a_Linux, this is the output:
terminate called after throwing an instance of ‘std::runtime_error’
what(): Failed to launch web window with error: Unable to launch the MATLABWindow application. The exit code was: 1
Aborted (core dumped)
When I then run ./bin/glnxa64/MATLABWindow , this is the output:
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /lib/x86_64-linux-gnu/libgallium-24.2.1 – kisak-mesa PPA.so)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `CXXABI_1.3.13′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.30′ not found (required by /lib/x86_64-linux-gnu/libLLVM-17.so.1)
./bin/glnxa64/MATLABWindow: /home/eric1/Downloads/matlab_R2024a_Linux/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.30′ not found (required by /lib/x86_64-linux-gnu/libicuuc.so.74)
I have tried reading through these guides:
https://www.mathworks.com/matlabcentral/answers/2018166-what-dependencies-are-needed-to-install-matlab-on-minimal-or-core-linux-installations
https://www.mathworks.com/matlabcentral/answers/540707-why-does-matlab-fail-to-install-with-a-std-runtime_error-what-unable-to-launch-the-matlabwind
I have tried other solutions on Stack Over flow and nothing has worked. ubuntu 24.04, installation MATLAB Answers — New Questions
Simulink and Git – Compare branches
Is there any way to compare Git branches on a Simulink project? In other words, show which files are different before merging.Is there any way to compare Git branches on a Simulink project? In other words, show which files are different before merging. Is there any way to compare Git branches on a Simulink project? In other words, show which files are different before merging. git MATLAB Answers — New Questions
How to List Hidden Group Memberships with the Graph
Administrative Interfaces Can List Hidden Group Memberships, but Graph-Based Apps Need Extra Permission
A user of the Microsoft 365 Groups and Teams activity report script (which I should do some work on to upgrade some really old code) pointed out that they weren’t getting details of groups with hidden membership. I’ve written about groups with hidden membership before and observed that administrative interfaces like the Microsoft 365 admin center or Entra admin center have access to hidden membership (Figure 1) where user-facing clients like Outlook block access to hidden group memberships.

PowerShell modules built for administrative use also count is administrative interfaces, so cmdlets like Get-UnifiedGroupLinks from the Exchange Online management module report hidden memberships as happily as they list open memberships. Modules like Exchange Online assume that anyone running their cmdlets is an administrator, so they extend the same access to data that the administrator enjoys through an admin portal.
Listing Hidden Group Memberships is Different with the Graph
The Graph API is different. Working on a least permission model, the Graph makes no assumptions about permissions when a session starts and the only access to data available during the session is via granted permissions. The permissions can be delegated (access to data available to the signed-in user) or application (available to tenant data). Delegated permissions are used for interactive sessions. Application permissions are used by apps (which can run in interactive sessions).
When the problem was first reported, I did a quick check but couldn’t find anything wrong. But I screwed up by running commands in an interactive session signed in with an account that held the Exchange administrator role. Interactive sessions use delegated permissions, but they also respect any of the administrative roles assigned to the account, so while the Get-MgGroupMember cmdlet would normally stop me seeing the members of a group with hidden membership, the Exchange administrator role removed the block and made the membership visible.
This experience proves once again that any testing for a Graph access scenario should be done with application permissions. In other words:
- Create an app (registration).
- Assign the app the lowest possible level of permissions you think are needed to get the job done.
- Test.
- Refine as necessary using different permissions until the test is successful.
Fetching Hidden Group Membership
In this scenario, I started off with an app with consent to use the Group.Read.All and User.Read.All permissions. The former is needed to read group details; the latter to retrieve member information (user accounts). I then disconnected my current interactive Microsoft Graph PowerShell SDK session and signed in with the app, using the thumbprint of an X.509 certificate uploaded to the app to authenticate. Running Get-MgContext confirmed the available permissions (scopes):
Connect-MgGraph -Tenantid $TenantId -AppId $AppId -CertificateThumbprint $Thumbprint (Get-MgContext).Scopes | Format-List User.Read.All Group.Read.All
Now attempt to read the membership of a group with hidden membership. The Get-MgGroupMember cmdlet returns nothing, but we know why because the visibility property of the group is set to HiddenMembership. A group might have no members, but if its visibility property is set to HiddenMembership, there might be data to retrieve,
Get-MgGroupMember -GroupId $GroupId Get-MgGroup -GroupId $GroupId | Select-Object Visibility Visibility ---------- HiddenMembership
The Visibility property is most often used to note whether a group has private or public membership. Unfortunately, it’s not a filterable property for the Graph, so to find the groups with hidden membership, you do something like this:
[array]$Groups = Get-MgGroup -All -PageSize 500 $Groups | Where-Object {$_.Visibility -eq 'HiddenMembership' } | Format-Table DisplayName, Id, Visibility
To find details of the hidden membership, grant consent for the app to use the Member.Read.Hidden permission. Disconnect and reconnect using the app and make sure that Member.Read.Hidden is available. Now run Get-MgGroupMember again:
[array]$Members = Get-MgGroupMember -GroupId $GroupId Id DeletedDateTime -- --------------- eff4cd58-1bb8-4899-94de-795f656b4a18 cad05ccf-a359-4ac7-89e0-1e33bf37579e 08dda855-5dc3-4fdc-8458-cbc494a5a774 75ba0efb-aed5-4c0b-a5de-be5b65187c08 4daa5f06-55eb-4d79-9a24-1be369919fec 59e09287-ac1b-4ff7-80a3-08d0d1eed939
Or to see the display names of the members:
$Members.additionalProperties.displayName Tony Redmond James Ryan Sean Landy Terry Hegarty Otto Flick Hans Geering (Project Management)
If an app has a higher-level permission, such as Directory.Read.All, it can also read hidden membership. The same permission governs access to hidden memberships of Entra ID groups and administrative units.
The Takeaway about Graph Permissions
The takeaway here is not to assume anything about Graph permissions. The ability of the Microsoft Graph Command Line Tools app (used for Microsoft Graph PowerShell SDK interactive sessions) to accrue delegated permissions over time is both a benefit and a problem. When you can, use app-only mode to validate exactly what permissions are required to run your code.
Need some assistance to write and manage PowerShell scripts for Microsoft 365? Get a copy of the Automating Microsoft 365 with PowerShell eBook, available standalone or as part of the Office 365 for IT Pros eBook bundle.
If I replace old version (R14) running on a 20 y.o laptop with Windows 7 with all new laptop, newest Windows and latest Matlab version, will my old toolboxes still be useable?
If I completely replace my old computer, windows 7 and R14 with the latest and greatest system and version, plus newest Windows, do I need to also buy the toolboxes that are part of my FSAE advisory and teaching package? Cost is not a high priority as much as will my dozens of old Vehicle Dynamics GUI and Fortran based packages still run, be salvagable, or do I start all over with the latest features ?If I completely replace my old computer, windows 7 and R14 with the latest and greatest system and version, plus newest Windows, do I need to also buy the toolboxes that are part of my FSAE advisory and teaching package? Cost is not a high priority as much as will my dozens of old Vehicle Dynamics GUI and Fortran based packages still run, be salvagable, or do I start all over with the latest features ? If I completely replace my old computer, windows 7 and R14 with the latest and greatest system and version, plus newest Windows, do I need to also buy the toolboxes that are part of my FSAE advisory and teaching package? Cost is not a high priority as much as will my dozens of old Vehicle Dynamics GUI and Fortran based packages still run, be salvagable, or do I start all over with the latest features ? replacement MATLAB Answers — New Questions
making the graphic smaller
hello, i am using the version 2024b, and i need help with something. in my figure window there’s an ekg signal and i want to make the ekg signal smaller only, not the figure window. scaling didnt help, maybe i did it wrong? i want it to look like the ones u get at the hospital; big paper, small looking signal. any tips?hello, i am using the version 2024b, and i need help with something. in my figure window there’s an ekg signal and i want to make the ekg signal smaller only, not the figure window. scaling didnt help, maybe i did it wrong? i want it to look like the ones u get at the hospital; big paper, small looking signal. any tips? hello, i am using the version 2024b, and i need help with something. in my figure window there’s an ekg signal and i want to make the ekg signal smaller only, not the figure window. scaling didnt help, maybe i did it wrong? i want it to look like the ones u get at the hospital; big paper, small looking signal. any tips? ekg, scaling figure MATLAB Answers — New Questions