Category: Matlab
Category Archives: Matlab
Matlab appdesigner – unused (noexistent) “_Label” public properties remain – how to remove them?
Dear community,
In my appdesigner application I have removed / renamed components, but some of their (already renamed/removed) public "_Label" properties (i.e. grayed) remain, although they are not referenced anymore.
Is there any way to "cleanup" the code, or to manually remove them?
Thank you in advance!Dear community,
In my appdesigner application I have removed / renamed components, but some of their (already renamed/removed) public "_Label" properties (i.e. grayed) remain, although they are not referenced anymore.
Is there any way to "cleanup" the code, or to manually remove them?
Thank you in advance! Dear community,
In my appdesigner application I have removed / renamed components, but some of their (already renamed/removed) public "_Label" properties (i.e. grayed) remain, although they are not referenced anymore.
Is there any way to "cleanup" the code, or to manually remove them?
Thank you in advance! matlab appdesigner public properties MATLAB Answers — New Questions
LSTM encoder-decoder model
I’d like to make LSTM encoder-decoder model with deep learning toolbox, whichbased on this link(this is for making same model with Keras). I’m trying to make the timeseries prediction(seq2seq).
https://machinelearningmastery.com/how-to-develop-lstm-models-for-multi-step-time-series-forecasting-of-household-power-consumption/
However, the corresponded warper layer fucvtions(ex TimeDistributed, RepeatVector) are not found in the deep learnig tool box.
Is there any solutions to make LSTM encoder-decoder model with Matlab.I’d like to make LSTM encoder-decoder model with deep learning toolbox, whichbased on this link(this is for making same model with Keras). I’m trying to make the timeseries prediction(seq2seq).
https://machinelearningmastery.com/how-to-develop-lstm-models-for-multi-step-time-series-forecasting-of-household-power-consumption/
However, the corresponded warper layer fucvtions(ex TimeDistributed, RepeatVector) are not found in the deep learnig tool box.
Is there any solutions to make LSTM encoder-decoder model with Matlab. I’d like to make LSTM encoder-decoder model with deep learning toolbox, whichbased on this link(this is for making same model with Keras). I’m trying to make the timeseries prediction(seq2seq).
https://machinelearningmastery.com/how-to-develop-lstm-models-for-multi-step-time-series-forecasting-of-household-power-consumption/
However, the corresponded warper layer fucvtions(ex TimeDistributed, RepeatVector) are not found in the deep learnig tool box.
Is there any solutions to make LSTM encoder-decoder model with Matlab. deep learning, lstm, encoder-decoder MATLAB Answers — New Questions
An easy way to input song chords into a structure of MATLAB
Hello. I’d like to know the way to enter the name of the song chords into the structure of MATLAB easily.
I do research about the related between chords and a piece of music, and I analyze the chords progression in MATLAB. Howerver, it takes too many time to enter the name of chords by hands like this;
chords = struct( …
‘name’, {}, … % name of chords(ex: ‘Cmaj7’)
‘start_sec’, {}, … % start time[s]
‘end_sec’, {} … % end time[s]
);
N=input(‘the number of chords: ‘);
BPM=input(‘BPM: ‘);
chords(1).start_sec=0;
for i=1:N
fprintf(‘n===== Chord %d =====n’, i);
chords(i).name=input(‘Name: ‘); %”
Start=input(‘Start beat: ‘);
chords(i).start_sec=(60/BPM)*4*(Start-1);
if i >= 2
chords(i-1).end_sec=(60/BPM)*4*(Start-1);
end
end
ends=input(‘End beat: ‘);
chords(N).end_sec=(60/BPM)*4*ends;
save("chords_yoruni.mat","chords");
I am a beginner when it comes to programming, so I don’t have any idea. I would like you to tell me even small things.
Thank you for your helpHello. I’d like to know the way to enter the name of the song chords into the structure of MATLAB easily.
I do research about the related between chords and a piece of music, and I analyze the chords progression in MATLAB. Howerver, it takes too many time to enter the name of chords by hands like this;
chords = struct( …
‘name’, {}, … % name of chords(ex: ‘Cmaj7’)
‘start_sec’, {}, … % start time[s]
‘end_sec’, {} … % end time[s]
);
N=input(‘the number of chords: ‘);
BPM=input(‘BPM: ‘);
chords(1).start_sec=0;
for i=1:N
fprintf(‘n===== Chord %d =====n’, i);
chords(i).name=input(‘Name: ‘); %”
Start=input(‘Start beat: ‘);
chords(i).start_sec=(60/BPM)*4*(Start-1);
if i >= 2
chords(i-1).end_sec=(60/BPM)*4*(Start-1);
end
end
ends=input(‘End beat: ‘);
chords(N).end_sec=(60/BPM)*4*ends;
save("chords_yoruni.mat","chords");
I am a beginner when it comes to programming, so I don’t have any idea. I would like you to tell me even small things.
Thank you for your help Hello. I’d like to know the way to enter the name of the song chords into the structure of MATLAB easily.
I do research about the related between chords and a piece of music, and I analyze the chords progression in MATLAB. Howerver, it takes too many time to enter the name of chords by hands like this;
chords = struct( …
‘name’, {}, … % name of chords(ex: ‘Cmaj7’)
‘start_sec’, {}, … % start time[s]
‘end_sec’, {} … % end time[s]
);
N=input(‘the number of chords: ‘);
BPM=input(‘BPM: ‘);
chords(1).start_sec=0;
for i=1:N
fprintf(‘n===== Chord %d =====n’, i);
chords(i).name=input(‘Name: ‘); %”
Start=input(‘Start beat: ‘);
chords(i).start_sec=(60/BPM)*4*(Start-1);
if i >= 2
chords(i-1).end_sec=(60/BPM)*4*(Start-1);
end
end
ends=input(‘End beat: ‘);
chords(N).end_sec=(60/BPM)*4*ends;
save("chords_yoruni.mat","chords");
I am a beginner when it comes to programming, so I don’t have any idea. I would like you to tell me even small things.
Thank you for your help music, input, chords MATLAB Answers — New Questions
How to install Matlab R2025B on WSL Ubuntu
I have downloaded the matlab_R2025b_Linux zipped file from MATLABS and unzipped it in WSL. However, when I try to run ./install or sudo ./install, nothing happens. There was no GUI pop up for the installation.
Following the instructions from the Installation Help pdf did not help either.I have downloaded the matlab_R2025b_Linux zipped file from MATLABS and unzipped it in WSL. However, when I try to run ./install or sudo ./install, nothing happens. There was no GUI pop up for the installation.
Following the instructions from the Installation Help pdf did not help either. I have downloaded the matlab_R2025b_Linux zipped file from MATLABS and unzipped it in WSL. However, when I try to run ./install or sudo ./install, nothing happens. There was no GUI pop up for the installation.
Following the instructions from the Installation Help pdf did not help either. matlab MATLAB Answers — New Questions
How to check that a matlab.ui.Figure handle is deleted?
There is a waitbar() in my application that shows the progress of a simulation. When an error in the simulation occurs, or when I debug the application, the waitbar windows stay on screen and I have to delete them manually.
I installed a cleanup with
fwaitbar = waitbar(0,’Running simulation of ‘+toml(cname)+’…’);
cleanup = onCleanup(@()killwaitbar(fwaitbar));
…
function killwaitbar(f)
close(f);
end
However, in case there in no error, MATLAB still runs killwaitbar(), and I get the error
Error using close
Invalid figure handle.
Error in R_nests>killwaitbar (line 431)
close(f);
Error in R_nests>@()killwaitbar(fwaitbar) (line 73)
cleanup = onCleanup(@()killwaitbar(fwaitbar));
Error in onCleanup/delete (line 25)
obj.task();
Error in R_nests (line 153)
end
In workspace belonging to R_nests>killwaitbar (line 431)
How can I test for this in the callback? ‘f’ is of class matlab.ui.Figure, but isa(f,’matlab.ui.Figure’) does not say anything about being deleted.
I am sure there is better way to do this but can’t find it.There is a waitbar() in my application that shows the progress of a simulation. When an error in the simulation occurs, or when I debug the application, the waitbar windows stay on screen and I have to delete them manually.
I installed a cleanup with
fwaitbar = waitbar(0,’Running simulation of ‘+toml(cname)+’…’);
cleanup = onCleanup(@()killwaitbar(fwaitbar));
…
function killwaitbar(f)
close(f);
end
However, in case there in no error, MATLAB still runs killwaitbar(), and I get the error
Error using close
Invalid figure handle.
Error in R_nests>killwaitbar (line 431)
close(f);
Error in R_nests>@()killwaitbar(fwaitbar) (line 73)
cleanup = onCleanup(@()killwaitbar(fwaitbar));
Error in onCleanup/delete (line 25)
obj.task();
Error in R_nests (line 153)
end
In workspace belonging to R_nests>killwaitbar (line 431)
How can I test for this in the callback? ‘f’ is of class matlab.ui.Figure, but isa(f,’matlab.ui.Figure’) does not say anything about being deleted.
I am sure there is better way to do this but can’t find it. There is a waitbar() in my application that shows the progress of a simulation. When an error in the simulation occurs, or when I debug the application, the waitbar windows stay on screen and I have to delete them manually.
I installed a cleanup with
fwaitbar = waitbar(0,’Running simulation of ‘+toml(cname)+’…’);
cleanup = onCleanup(@()killwaitbar(fwaitbar));
…
function killwaitbar(f)
close(f);
end
However, in case there in no error, MATLAB still runs killwaitbar(), and I get the error
Error using close
Invalid figure handle.
Error in R_nests>killwaitbar (line 431)
close(f);
Error in R_nests>@()killwaitbar(fwaitbar) (line 73)
cleanup = onCleanup(@()killwaitbar(fwaitbar));
Error in onCleanup/delete (line 25)
obj.task();
Error in R_nests (line 153)
end
In workspace belonging to R_nests>killwaitbar (line 431)
How can I test for this in the callback? ‘f’ is of class matlab.ui.Figure, but isa(f,’matlab.ui.Figure’) does not say anything about being deleted.
I am sure there is better way to do this but can’t find it. waitbar, gui, cleanup, matlab.ui.figure MATLAB Answers — New Questions
Variables Window unusable in Matlab 2025
Unfortunately, the switch to MATLAB 2025 has made the Variable Editor unusable. This is due to two issues:
Variables are not displayed immediately in the Variable Editor. When double-clicking a variable in the workspace, sometimes one and sometimes two windows open—one of which is always empty and shows a loading circle.
When using copy-paste, entire rows or columns are no longer copied. Instead, only a portion is copied, which changes simply by scrolling within the Variable Editor.
As a result, I can no longer use MATLAB effectively, since I frequently need to copy and move large sets of measurement data.
Is this a known issue, or is my PC simply too old/slow/faulty?
Best regards,
JanUnfortunately, the switch to MATLAB 2025 has made the Variable Editor unusable. This is due to two issues:
Variables are not displayed immediately in the Variable Editor. When double-clicking a variable in the workspace, sometimes one and sometimes two windows open—one of which is always empty and shows a loading circle.
When using copy-paste, entire rows or columns are no longer copied. Instead, only a portion is copied, which changes simply by scrolling within the Variable Editor.
As a result, I can no longer use MATLAB effectively, since I frequently need to copy and move large sets of measurement data.
Is this a known issue, or is my PC simply too old/slow/faulty?
Best regards,
Jan Unfortunately, the switch to MATLAB 2025 has made the Variable Editor unusable. This is due to two issues:
Variables are not displayed immediately in the Variable Editor. When double-clicking a variable in the workspace, sometimes one and sometimes two windows open—one of which is always empty and shows a loading circle.
When using copy-paste, entire rows or columns are no longer copied. Instead, only a portion is copied, which changes simply by scrolling within the Variable Editor.
As a result, I can no longer use MATLAB effectively, since I frequently need to copy and move large sets of measurement data.
Is this a known issue, or is my PC simply too old/slow/faulty?
Best regards,
Jan variables windows, copy-paste, loading circle MATLAB Answers — New Questions
Request to rehost MATLAB network license (1102419) to new server IP
the user, trying to install MATLAB on their lab server’s head node for SLURM usage. The earlier license I received from SERC is not valid as it is locked to a different IP address than what is being used by our server.
The current license is bound to:
HostID (INTERNET): 10.16.4.41
Whereas our lab server’s primary IP address is:
10.10.100.152
Could you please rehost MATLAB network license 1102419 in the MathWorks License Center to this new IP (10.10.100.152) and provide the updated network license file or passcode for R2025b?
We already have MATLAB and the Network License Manager installed on the server; only the rehosted license is required to bring the system online.the user, trying to install MATLAB on their lab server’s head node for SLURM usage. The earlier license I received from SERC is not valid as it is locked to a different IP address than what is being used by our server.
The current license is bound to:
HostID (INTERNET): 10.16.4.41
Whereas our lab server’s primary IP address is:
10.10.100.152
Could you please rehost MATLAB network license 1102419 in the MathWorks License Center to this new IP (10.10.100.152) and provide the updated network license file or passcode for R2025b?
We already have MATLAB and the Network License Manager installed on the server; only the rehosted license is required to bring the system online. the user, trying to install MATLAB on their lab server’s head node for SLURM usage. The earlier license I received from SERC is not valid as it is locked to a different IP address than what is being used by our server.
The current license is bound to:
HostID (INTERNET): 10.16.4.41
Whereas our lab server’s primary IP address is:
10.10.100.152
Could you please rehost MATLAB network license 1102419 in the MathWorks License Center to this new IP (10.10.100.152) and provide the updated network license file or passcode for R2025b?
We already have MATLAB and the Network License Manager installed on the server; only the rehosted license is required to bring the system online. rehost MATLAB Answers — New Questions
I have changed schools, and the old academic email no longer works, how do I link my student license to a new email?
I am attending a different university, and my old email address that is linked to my student license is no longer active. How do I link my license to a new academic email account.I am attending a different university, and my old email address that is linked to my student license is no longer active. How do I link my license to a new academic email account. I am attending a different university, and my old email address that is linked to my student license is no longer active. How do I link my license to a new academic email account. new email MATLAB Answers — New Questions
solving a system of linear equations where A is a 40*40 sparse matrix
Hi there,
I am solving a system of linear equations A*x=b , where A is a 40*40 sparse matrix. Should I use inv or to reach a more precise answer x?Hi there,
I am solving a system of linear equations A*x=b , where A is a 40*40 sparse matrix. Should I use inv or to reach a more precise answer x? Hi there,
I am solving a system of linear equations A*x=b , where A is a 40*40 sparse matrix. Should I use inv or to reach a more precise answer x? sparse matrix, a system of linear equations MATLAB Answers — New Questions
How to share the same Referenced Configs on Multi-rate systems
I am working on a project with different Software Components in Simulink. The Components are intended to share the same Configuration. However the Sampling time can differ. For this purpose, the Sampling time is defined as a variable "Ts". Every Software component has, on its own data dictionary, a variable "Ts" .
However, when I try to place both Software components (as referenced subsystems) on a model (for Model in Loop simulation), I get the following error:
Symbol ‘Ts’ has multiple inconsistent definitions:
Caused by:
value=0.2 in Model1.sldd (Update others to match)
value=0.025 in Model2.sldd (Update others to match)
Component:Simulink | Category:Model error
Is it possible to still use the same referenced configuration for all the models, in a way that simulations with two or more Software Components with different data rates still work?I am working on a project with different Software Components in Simulink. The Components are intended to share the same Configuration. However the Sampling time can differ. For this purpose, the Sampling time is defined as a variable "Ts". Every Software component has, on its own data dictionary, a variable "Ts" .
However, when I try to place both Software components (as referenced subsystems) on a model (for Model in Loop simulation), I get the following error:
Symbol ‘Ts’ has multiple inconsistent definitions:
Caused by:
value=0.2 in Model1.sldd (Update others to match)
value=0.025 in Model2.sldd (Update others to match)
Component:Simulink | Category:Model error
Is it possible to still use the same referenced configuration for all the models, in a way that simulations with two or more Software Components with different data rates still work? I am working on a project with different Software Components in Simulink. The Components are intended to share the same Configuration. However the Sampling time can differ. For this purpose, the Sampling time is defined as a variable "Ts". Every Software component has, on its own data dictionary, a variable "Ts" .
However, when I try to place both Software components (as referenced subsystems) on a model (for Model in Loop simulation), I get the following error:
Symbol ‘Ts’ has multiple inconsistent definitions:
Caused by:
value=0.2 in Model1.sldd (Update others to match)
value=0.025 in Model2.sldd (Update others to match)
Component:Simulink | Category:Model error
Is it possible to still use the same referenced configuration for all the models, in a way that simulations with two or more Software Components with different data rates still work? simulink MATLAB Answers — New Questions
File Exchange entries not updating after new versions in GitHub
I am an administrator on two GitHub repos that have File Exchange entries:
https://www.mathworks.com/matlabcentral/fileexchange/134991-deepinterpolation-matlab
https://www.mathworks.com/matlabcentral/fileexchange/90900-brain-observatory-toolbox
Right now neither file exchange entry has updated (after 3 days) in response to a new version marked as "latest release" on the corresponding GitHub repos. Typically, they have in the past.
Any clues?I am an administrator on two GitHub repos that have File Exchange entries:
https://www.mathworks.com/matlabcentral/fileexchange/134991-deepinterpolation-matlab
https://www.mathworks.com/matlabcentral/fileexchange/90900-brain-observatory-toolbox
Right now neither file exchange entry has updated (after 3 days) in response to a new version marked as "latest release" on the corresponding GitHub repos. Typically, they have in the past.
Any clues? I am an administrator on two GitHub repos that have File Exchange entries:
https://www.mathworks.com/matlabcentral/fileexchange/134991-deepinterpolation-matlab
https://www.mathworks.com/matlabcentral/fileexchange/90900-brain-observatory-toolbox
Right now neither file exchange entry has updated (after 3 days) in response to a new version marked as "latest release" on the corresponding GitHub repos. Typically, they have in the past.
Any clues? file exchange, github MATLAB Answers — New Questions
How can I calculate the Variance Inflation Factor (VIF) for a linear regression model
I have a long set of linear models developed from a space-filling DOE I ran. Many of the parameters in the DOE are correlated to different degrees and I’m interested in calculating the VIF of each parameter, and recalculating the model if the VIF for some parameters is high. I saw this code in another answer https://www.mathworks.com/matlabcentral/answers/1964984-tolerance-value-and-variance-inflation-factor-in-stepwiselm
% Define the predictors and response variable
X = [x1, x2, x3, x4, x5];
Y = y;
% Define the options for stepwise regression
options = statset(‘Display’,’iter’, ‘TolFun’, 0.01, ‘TolTypeFun’, ‘rel’, ‘PEnter’, 0.05, ‘PRemove’, 0.1);
% Run the stepwise regression with predefined multicollinearity threshold settings
mdl = stepwiselm(X, Y, ‘Criterion’, ‘bic’, ‘Upper’, ‘linear’, ‘Lower’, ‘constant’, ‘PEnter’, 0.05, ‘PRemove’, 0.1, ‘Verbose’, 1, ‘Options’, options);
% Check the multicollinearity
[vif, tolerance] = vif(mdl);
% Check for variable inclusion
included_vars = mdl.predictorNames(mdl.Coefficients.Estimate ~= 0);
However, I ran into a couple problems when trying to execute this snippet.
1) statset doesn’t take ‘PEnter’ or ‘PRemove’ as arguments. Removing those two arguments allowed that line to run.
2) stepwiselm doesn’t seem to take ‘Options’ as a valid argument
3) I can’t seem to find a function called vif that takes a linear model object as an argument
I have the curve fitting, data acquisition, deep learning, and statistics toolboxes installed. If there is another toolbox with applicable functions I can install that as well.I have a long set of linear models developed from a space-filling DOE I ran. Many of the parameters in the DOE are correlated to different degrees and I’m interested in calculating the VIF of each parameter, and recalculating the model if the VIF for some parameters is high. I saw this code in another answer https://www.mathworks.com/matlabcentral/answers/1964984-tolerance-value-and-variance-inflation-factor-in-stepwiselm
% Define the predictors and response variable
X = [x1, x2, x3, x4, x5];
Y = y;
% Define the options for stepwise regression
options = statset(‘Display’,’iter’, ‘TolFun’, 0.01, ‘TolTypeFun’, ‘rel’, ‘PEnter’, 0.05, ‘PRemove’, 0.1);
% Run the stepwise regression with predefined multicollinearity threshold settings
mdl = stepwiselm(X, Y, ‘Criterion’, ‘bic’, ‘Upper’, ‘linear’, ‘Lower’, ‘constant’, ‘PEnter’, 0.05, ‘PRemove’, 0.1, ‘Verbose’, 1, ‘Options’, options);
% Check the multicollinearity
[vif, tolerance] = vif(mdl);
% Check for variable inclusion
included_vars = mdl.predictorNames(mdl.Coefficients.Estimate ~= 0);
However, I ran into a couple problems when trying to execute this snippet.
1) statset doesn’t take ‘PEnter’ or ‘PRemove’ as arguments. Removing those two arguments allowed that line to run.
2) stepwiselm doesn’t seem to take ‘Options’ as a valid argument
3) I can’t seem to find a function called vif that takes a linear model object as an argument
I have the curve fitting, data acquisition, deep learning, and statistics toolboxes installed. If there is another toolbox with applicable functions I can install that as well. I have a long set of linear models developed from a space-filling DOE I ran. Many of the parameters in the DOE are correlated to different degrees and I’m interested in calculating the VIF of each parameter, and recalculating the model if the VIF for some parameters is high. I saw this code in another answer https://www.mathworks.com/matlabcentral/answers/1964984-tolerance-value-and-variance-inflation-factor-in-stepwiselm
% Define the predictors and response variable
X = [x1, x2, x3, x4, x5];
Y = y;
% Define the options for stepwise regression
options = statset(‘Display’,’iter’, ‘TolFun’, 0.01, ‘TolTypeFun’, ‘rel’, ‘PEnter’, 0.05, ‘PRemove’, 0.1);
% Run the stepwise regression with predefined multicollinearity threshold settings
mdl = stepwiselm(X, Y, ‘Criterion’, ‘bic’, ‘Upper’, ‘linear’, ‘Lower’, ‘constant’, ‘PEnter’, 0.05, ‘PRemove’, 0.1, ‘Verbose’, 1, ‘Options’, options);
% Check the multicollinearity
[vif, tolerance] = vif(mdl);
% Check for variable inclusion
included_vars = mdl.predictorNames(mdl.Coefficients.Estimate ~= 0);
However, I ran into a couple problems when trying to execute this snippet.
1) statset doesn’t take ‘PEnter’ or ‘PRemove’ as arguments. Removing those two arguments allowed that line to run.
2) stepwiselm doesn’t seem to take ‘Options’ as a valid argument
3) I can’t seem to find a function called vif that takes a linear model object as an argument
I have the curve fitting, data acquisition, deep learning, and statistics toolboxes installed. If there is another toolbox with applicable functions I can install that as well. regression, curve fitting MATLAB Answers — New Questions
unexpected axes orientation in volshow()
Matlab documentation recommends using volshow() to display nifti-format images. volshow() does NOT map the indices i,j,k to the x,y,z axes, contrary to the nifti format specification. Have others noticed this? Do you see it as a problem? Could this cause medical scans to display in mirror image from what they should be?
The nifti format specification (nifti1.h, here) says that the indices i,j,k in V(i,j,k) map to x,y,z respectively, by default. (This is called Method 1 in lines 1038-1040 of nifti1.h.) Since I have not specified otherwise, I expect the default method to be used. Furthermore, if I do specify a mapping, using the an affine transform with the identity matrix, i,j,k should map to x,y,z respectively, but they do not. This method is called Method 3 in lines 1101-1103 of the nifti1.h specification. In case you’re wondering, the nifti1.h file also explains at lines 1008-1011 that the first, second,third array indices (i,j,k) should change fastest, medium, slowest respectively, as the array is stored in memory. And that is how Matlab array indices work.
Whether I use Method 1 or 3, index i maps to y and index j maps to x, contrary to expectation.
The code below demonstrates this by making and plotting a 3D scan. The volume V is 99x99x99. It has three lines from the center leading out to the centers of the imax face, the jmax face, and the kmax face. At the max end of each line, there are different size squares, to allow us to tell which is which. The imax face has a small square, the jmax face has a large square, and the kmax face has a medium square. I expect these to be at the +x, +y, and +z axes, respectively, but the large and small are reversed (x-y) from what I expect. This is not just a rotation of the data, it is a reflection, since data expected at +x and +y are flipped. See below.
Other things I’ve tried:
Write the volume to a nifti file, then read it in, then display it. Same result.
Define tform=affinetform3d(eye(4)); and use it: volshow(V,Transformation=tform);. Same result.
I realize that I can use an affine transformation (reflection) S=[0,1,0,0; 1,0,0,0; 0,0,1,0; 0,0,0,1] to make this look like I expected. But I think I shouldn’t have to, or it should be documented.
Since volshow() does not display in Matlab Answers, I have attached a screenshot of the displayed volume that results from the code below.
imax=99; jmax=99; kmax=99; % volume dimensions
V=zeros(imax,jmax,kmax); % allocate array
% draw line from cube center to center of imax face
V(50:imax,50,50)=ones(50,1,1);
% draw line from cube center to center of jmax face
V(50,50:jmax,50)=ones(1,50,1);
% draw line from cube center to center of kmax face
V(50,50,50:kmax)=ones(1,1,50);
% small (9×9) square at center of imax face (imax,jmid,kmid)
V(imax,46:54,46:54)=ones(1,9,9);
% large (21×21) square at center of jmax face (imid, jmax, kmid)
V(40:60,jmax,40:60)=ones(21,1,21);
% medium (15×15) square at center of kmax face (imid, jmid, kmax)
V(43:57,43:57,kmax)=ones(15,15,1);
% Display simulated scan
volshow(V);Matlab documentation recommends using volshow() to display nifti-format images. volshow() does NOT map the indices i,j,k to the x,y,z axes, contrary to the nifti format specification. Have others noticed this? Do you see it as a problem? Could this cause medical scans to display in mirror image from what they should be?
The nifti format specification (nifti1.h, here) says that the indices i,j,k in V(i,j,k) map to x,y,z respectively, by default. (This is called Method 1 in lines 1038-1040 of nifti1.h.) Since I have not specified otherwise, I expect the default method to be used. Furthermore, if I do specify a mapping, using the an affine transform with the identity matrix, i,j,k should map to x,y,z respectively, but they do not. This method is called Method 3 in lines 1101-1103 of the nifti1.h specification. In case you’re wondering, the nifti1.h file also explains at lines 1008-1011 that the first, second,third array indices (i,j,k) should change fastest, medium, slowest respectively, as the array is stored in memory. And that is how Matlab array indices work.
Whether I use Method 1 or 3, index i maps to y and index j maps to x, contrary to expectation.
The code below demonstrates this by making and plotting a 3D scan. The volume V is 99x99x99. It has three lines from the center leading out to the centers of the imax face, the jmax face, and the kmax face. At the max end of each line, there are different size squares, to allow us to tell which is which. The imax face has a small square, the jmax face has a large square, and the kmax face has a medium square. I expect these to be at the +x, +y, and +z axes, respectively, but the large and small are reversed (x-y) from what I expect. This is not just a rotation of the data, it is a reflection, since data expected at +x and +y are flipped. See below.
Other things I’ve tried:
Write the volume to a nifti file, then read it in, then display it. Same result.
Define tform=affinetform3d(eye(4)); and use it: volshow(V,Transformation=tform);. Same result.
I realize that I can use an affine transformation (reflection) S=[0,1,0,0; 1,0,0,0; 0,0,1,0; 0,0,0,1] to make this look like I expected. But I think I shouldn’t have to, or it should be documented.
Since volshow() does not display in Matlab Answers, I have attached a screenshot of the displayed volume that results from the code below.
imax=99; jmax=99; kmax=99; % volume dimensions
V=zeros(imax,jmax,kmax); % allocate array
% draw line from cube center to center of imax face
V(50:imax,50,50)=ones(50,1,1);
% draw line from cube center to center of jmax face
V(50,50:jmax,50)=ones(1,50,1);
% draw line from cube center to center of kmax face
V(50,50,50:kmax)=ones(1,1,50);
% small (9×9) square at center of imax face (imax,jmid,kmid)
V(imax,46:54,46:54)=ones(1,9,9);
% large (21×21) square at center of jmax face (imid, jmax, kmid)
V(40:60,jmax,40:60)=ones(21,1,21);
% medium (15×15) square at center of kmax face (imid, jmid, kmax)
V(43:57,43:57,kmax)=ones(15,15,1);
% Display simulated scan
volshow(V); Matlab documentation recommends using volshow() to display nifti-format images. volshow() does NOT map the indices i,j,k to the x,y,z axes, contrary to the nifti format specification. Have others noticed this? Do you see it as a problem? Could this cause medical scans to display in mirror image from what they should be?
The nifti format specification (nifti1.h, here) says that the indices i,j,k in V(i,j,k) map to x,y,z respectively, by default. (This is called Method 1 in lines 1038-1040 of nifti1.h.) Since I have not specified otherwise, I expect the default method to be used. Furthermore, if I do specify a mapping, using the an affine transform with the identity matrix, i,j,k should map to x,y,z respectively, but they do not. This method is called Method 3 in lines 1101-1103 of the nifti1.h specification. In case you’re wondering, the nifti1.h file also explains at lines 1008-1011 that the first, second,third array indices (i,j,k) should change fastest, medium, slowest respectively, as the array is stored in memory. And that is how Matlab array indices work.
Whether I use Method 1 or 3, index i maps to y and index j maps to x, contrary to expectation.
The code below demonstrates this by making and plotting a 3D scan. The volume V is 99x99x99. It has three lines from the center leading out to the centers of the imax face, the jmax face, and the kmax face. At the max end of each line, there are different size squares, to allow us to tell which is which. The imax face has a small square, the jmax face has a large square, and the kmax face has a medium square. I expect these to be at the +x, +y, and +z axes, respectively, but the large and small are reversed (x-y) from what I expect. This is not just a rotation of the data, it is a reflection, since data expected at +x and +y are flipped. See below.
Other things I’ve tried:
Write the volume to a nifti file, then read it in, then display it. Same result.
Define tform=affinetform3d(eye(4)); and use it: volshow(V,Transformation=tform);. Same result.
I realize that I can use an affine transformation (reflection) S=[0,1,0,0; 1,0,0,0; 0,0,1,0; 0,0,0,1] to make this look like I expected. But I think I shouldn’t have to, or it should be documented.
Since volshow() does not display in Matlab Answers, I have attached a screenshot of the displayed volume that results from the code below.
imax=99; jmax=99; kmax=99; % volume dimensions
V=zeros(imax,jmax,kmax); % allocate array
% draw line from cube center to center of imax face
V(50:imax,50,50)=ones(50,1,1);
% draw line from cube center to center of jmax face
V(50,50:jmax,50)=ones(1,50,1);
% draw line from cube center to center of kmax face
V(50,50,50:kmax)=ones(1,1,50);
% small (9×9) square at center of imax face (imax,jmid,kmid)
V(imax,46:54,46:54)=ones(1,9,9);
% large (21×21) square at center of jmax face (imid, jmax, kmid)
V(40:60,jmax,40:60)=ones(21,1,21);
% medium (15×15) square at center of kmax face (imid, jmid, kmax)
V(43:57,43:57,kmax)=ones(15,15,1);
% Display simulated scan
volshow(V); nifti, volshow, medical image MATLAB Answers — New Questions
PID Controller output the results of integral gain
Can the Discrete PID Controller module output the results of integral gain in real-time?Can the Discrete PID Controller module output the results of integral gain in real-time? Can the Discrete PID Controller module output the results of integral gain in real-time? simulink, pid module MATLAB Answers — New Questions
i complete the simulink,but have to calculate the response time,thd and efficiency for dvr with flc.how can i sort out this?
dvr with flc for power quality improvement. i have to find out response time,thd,efficency, how to sort out this. can anyone help me with this.dvr with flc for power quality improvement. i have to find out response time,thd,efficency, how to sort out this. can anyone help me with this. dvr with flc for power quality improvement. i have to find out response time,thd,efficency, how to sort out this. can anyone help me with this. matlab, simulation MATLAB Answers — New Questions
Transfer License
I would like to transfer my Matlab and Simulink licenses to a new person in the company. How can I accomplish that?
Thank you.I would like to transfer my Matlab and Simulink licenses to a new person in the company. How can I accomplish that?
Thank you. I would like to transfer my Matlab and Simulink licenses to a new person in the company. How can I accomplish that?
Thank you. matlab, license MATLAB Answers — New Questions
Matlab issue with Jetpack Jetson AGX Orin
I am having a problem detecting cameras in my jetson AGX orin. On the jetson itself, it looks fine. When i plug a camera into the USB, it shows up fine in the matlab window. However I am using these cameras:
https://www.e-consystems.com/nvidia-cameras/jetson-agx-orin-cameras/ar0234-fhd-gmsl2-global-shutter-camera.asp
Checking for CUDA availability on the Target…
Checking for ‘nvcc’ in the target system path…
Checking for cuDNN library availability on the Target…
Checking for TensorRT library availability on the Target…
Checking for prerequisite libraries is complete.
Gathering hardware details…
Checking for third-party library availability on the Target…
Gathering hardware details is complete.
Board name : NVIDIA Jetson AGX Orin Developer Kit
CUDA Version : 12.6
cuDNN Version : 9.3
TensorRT Version : 10.
GStreamer Version : 1.20.3
V4L2 Version : 1.22.1-2build1
SDL Version : 1.2
OpenCV Version : 4.8.0
Available Webcams :
Available GPUs : Orin
Available Digital Pins : 7 11 12 13 15 16 18 19 21 22 23 24 26 29 31 32 33 35 36 37 38 40
I believe i’m running jetpack 6.
getCameraList(hwobj)
Camera Name Video Device Available Resolutions Pixel Formats
______________________________ _____________ ________________________________________ _____________
"vi-output, ecam_gmsl 9-0044" "/dev/video0" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
"vi-output, ecam_gmsl 10-0043" "/dev/video1" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
"vi-output, ecam_gmsl 10-0044" "/dev/video2" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
when i try to run the folloiwng command ige tan error:
cam = camera(hwobj, ‘vi-output, ecam_gmsl 9-0044’, [1280 720]);
img = snapshot(cam);
Error using nvidiaboard/recvResponse
Unable to pull the frame.
Error in nvidiaio.internal.camera/open (line 262)
obj.ConnectedCamera = obj.NvObj.recvResponse() + 1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in nvidiaio.internal.camera (line 109)
obj.open();
^^^^^^^^^^^
Error in nvidiaboard/camera
this shows up no matter what camera i use, and whatever resoluition I use.I am having a problem detecting cameras in my jetson AGX orin. On the jetson itself, it looks fine. When i plug a camera into the USB, it shows up fine in the matlab window. However I am using these cameras:
https://www.e-consystems.com/nvidia-cameras/jetson-agx-orin-cameras/ar0234-fhd-gmsl2-global-shutter-camera.asp
Checking for CUDA availability on the Target…
Checking for ‘nvcc’ in the target system path…
Checking for cuDNN library availability on the Target…
Checking for TensorRT library availability on the Target…
Checking for prerequisite libraries is complete.
Gathering hardware details…
Checking for third-party library availability on the Target…
Gathering hardware details is complete.
Board name : NVIDIA Jetson AGX Orin Developer Kit
CUDA Version : 12.6
cuDNN Version : 9.3
TensorRT Version : 10.
GStreamer Version : 1.20.3
V4L2 Version : 1.22.1-2build1
SDL Version : 1.2
OpenCV Version : 4.8.0
Available Webcams :
Available GPUs : Orin
Available Digital Pins : 7 11 12 13 15 16 18 19 21 22 23 24 26 29 31 32 33 35 36 37 38 40
I believe i’m running jetpack 6.
getCameraList(hwobj)
Camera Name Video Device Available Resolutions Pixel Formats
______________________________ _____________ ________________________________________ _____________
"vi-output, ecam_gmsl 9-0044" "/dev/video0" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
"vi-output, ecam_gmsl 10-0043" "/dev/video1" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
"vi-output, ecam_gmsl 10-0044" "/dev/video2" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
when i try to run the folloiwng command ige tan error:
cam = camera(hwobj, ‘vi-output, ecam_gmsl 9-0044’, [1280 720]);
img = snapshot(cam);
Error using nvidiaboard/recvResponse
Unable to pull the frame.
Error in nvidiaio.internal.camera/open (line 262)
obj.ConnectedCamera = obj.NvObj.recvResponse() + 1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in nvidiaio.internal.camera (line 109)
obj.open();
^^^^^^^^^^^
Error in nvidiaboard/camera
this shows up no matter what camera i use, and whatever resoluition I use. I am having a problem detecting cameras in my jetson AGX orin. On the jetson itself, it looks fine. When i plug a camera into the USB, it shows up fine in the matlab window. However I am using these cameras:
https://www.e-consystems.com/nvidia-cameras/jetson-agx-orin-cameras/ar0234-fhd-gmsl2-global-shutter-camera.asp
Checking for CUDA availability on the Target…
Checking for ‘nvcc’ in the target system path…
Checking for cuDNN library availability on the Target…
Checking for TensorRT library availability on the Target…
Checking for prerequisite libraries is complete.
Gathering hardware details…
Checking for third-party library availability on the Target…
Gathering hardware details is complete.
Board name : NVIDIA Jetson AGX Orin Developer Kit
CUDA Version : 12.6
cuDNN Version : 9.3
TensorRT Version : 10.
GStreamer Version : 1.20.3
V4L2 Version : 1.22.1-2build1
SDL Version : 1.2
OpenCV Version : 4.8.0
Available Webcams :
Available GPUs : Orin
Available Digital Pins : 7 11 12 13 15 16 18 19 21 22 23 24 26 29 31 32 33 35 36 37 38 40
I believe i’m running jetpack 6.
getCameraList(hwobj)
Camera Name Video Device Available Resolutions Pixel Formats
______________________________ _____________ ________________________________________ _____________
"vi-output, ecam_gmsl 9-0044" "/dev/video0" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
"vi-output, ecam_gmsl 10-0043" "/dev/video1" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
"vi-output, ecam_gmsl 10-0044" "/dev/video2" "[1280 720],[1920 1080],[1920 1200]" "UYVY,NV16"
when i try to run the folloiwng command ige tan error:
cam = camera(hwobj, ‘vi-output, ecam_gmsl 9-0044’, [1280 720]);
img = snapshot(cam);
Error using nvidiaboard/recvResponse
Unable to pull the frame.
Error in nvidiaio.internal.camera/open (line 262)
obj.ConnectedCamera = obj.NvObj.recvResponse() + 1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in nvidiaio.internal.camera (line 109)
obj.open();
^^^^^^^^^^^
Error in nvidiaboard/camera
this shows up no matter what camera i use, and whatever resoluition I use. jetson, orin MATLAB Answers — New Questions
Is the Order of Function Evaluation Guaranteed when Function Outputs are Concatenated into an an Array?
Suppose I call two functions within concatenation into an array
A = [ones(1,2),zeros(1,2)]
In this case, the order in which ones and zeros are evaluated doesn’t matter as far as the result is concerned.
But what about when there is dependence between the two (or more) functions whose outputs are being concatenated:
A = [figure,plot(1:3)]
Is there any guarantee that the call to figure is evaluated and the figure created before the call to plot so that the plotted result is in the newly created figure?
Does the answer change if creating a cell array?
A= {figure,plot(rand(2))}Suppose I call two functions within concatenation into an array
A = [ones(1,2),zeros(1,2)]
In this case, the order in which ones and zeros are evaluated doesn’t matter as far as the result is concerned.
But what about when there is dependence between the two (or more) functions whose outputs are being concatenated:
A = [figure,plot(1:3)]
Is there any guarantee that the call to figure is evaluated and the figure created before the call to plot so that the plotted result is in the newly created figure?
Does the answer change if creating a cell array?
A= {figure,plot(rand(2))} Suppose I call two functions within concatenation into an array
A = [ones(1,2),zeros(1,2)]
In this case, the order in which ones and zeros are evaluated doesn’t matter as far as the result is concerned.
But what about when there is dependence between the two (or more) functions whose outputs are being concatenated:
A = [figure,plot(1:3)]
Is there any guarantee that the call to figure is evaluated and the figure created before the call to plot so that the plotted result is in the newly created figure?
Does the answer change if creating a cell array?
A= {figure,plot(rand(2))} function evaluation, concatenation MATLAB Answers — New Questions
any way of processing callbacks without updating figures?
Is there any way of processing callbacks without updating the figures? I know that drawnow can update the figures without processing callbacks, but is there some way of doing the opposite? In the code I’m writing, the callbacks are important and need to be handled regularly, but updating the figures is lower priority. I also tried pause(0), but I didn’t see any difference between that and drawnow.Is there any way of processing callbacks without updating the figures? I know that drawnow can update the figures without processing callbacks, but is there some way of doing the opposite? In the code I’m writing, the callbacks are important and need to be handled regularly, but updating the figures is lower priority. I also tried pause(0), but I didn’t see any difference between that and drawnow. Is there any way of processing callbacks without updating the figures? I know that drawnow can update the figures without processing callbacks, but is there some way of doing the opposite? In the code I’m writing, the callbacks are important and need to be handled regularly, but updating the figures is lower priority. I also tried pause(0), but I didn’t see any difference between that and drawnow. callbacks, drawnow MATLAB Answers — New Questions
Control System for a Thermoelectric Cooler in Matlab & Simulink
I’m looking to model the control system block diagram for a thermoelectric cooler (TEC), that will be used in a small fridge. I’ve used the "Control Systems" toolbox to create block diagrams and get transient and steady state responses before for classes, however the transfer functions were often given or easy to solve. In this case, I’m stuck at finding the transfer function of the TEC, and how to incorporate it into a system. I recently learned about the simscape electronics toolbox that has a TEC block available, and a tutorial on how to use it, however I am unsure of how (or if) that would work with the control systems toolbox.
For some additional information on what I’m trying to acheive, here is an application note on a similar project. I’m mostly trying to recreate Figure 2 from Maxim Integrated’s APPLICATION NOTE 5424. I haven’t picked out exact components yet.
I’m new to control systems, matlab, simulink, and TECs, so any information would be greatly appreciated! And if I am going about this all wrong, a new direction would be appreciated as well.I’m looking to model the control system block diagram for a thermoelectric cooler (TEC), that will be used in a small fridge. I’ve used the "Control Systems" toolbox to create block diagrams and get transient and steady state responses before for classes, however the transfer functions were often given or easy to solve. In this case, I’m stuck at finding the transfer function of the TEC, and how to incorporate it into a system. I recently learned about the simscape electronics toolbox that has a TEC block available, and a tutorial on how to use it, however I am unsure of how (or if) that would work with the control systems toolbox.
For some additional information on what I’m trying to acheive, here is an application note on a similar project. I’m mostly trying to recreate Figure 2 from Maxim Integrated’s APPLICATION NOTE 5424. I haven’t picked out exact components yet.
I’m new to control systems, matlab, simulink, and TECs, so any information would be greatly appreciated! And if I am going about this all wrong, a new direction would be appreciated as well. I’m looking to model the control system block diagram for a thermoelectric cooler (TEC), that will be used in a small fridge. I’ve used the "Control Systems" toolbox to create block diagrams and get transient and steady state responses before for classes, however the transfer functions were often given or easy to solve. In this case, I’m stuck at finding the transfer function of the TEC, and how to incorporate it into a system. I recently learned about the simscape electronics toolbox that has a TEC block available, and a tutorial on how to use it, however I am unsure of how (or if) that would work with the control systems toolbox.
For some additional information on what I’m trying to acheive, here is an application note on a similar project. I’m mostly trying to recreate Figure 2 from Maxim Integrated’s APPLICATION NOTE 5424. I haven’t picked out exact components yet.
I’m new to control systems, matlab, simulink, and TECs, so any information would be greatly appreciated! And if I am going about this all wrong, a new direction would be appreciated as well. tec, controlsystems, peltiercooler MATLAB Answers — New Questions









