Tag Archives: matlab
Can I use the Simulink Solver profiler programmatically?
I want to view Solver Profiler output for a variety of Simulink simulations, and currently I am running them one by one in the Solver Profiler window to achieve this. I would like to batch run them overnight and view profiler results afterwards, is this possible?I want to view Solver Profiler output for a variety of Simulink simulations, and currently I am running them one by one in the Solver Profiler window to achieve this. I would like to batch run them overnight and view profiler results afterwards, is this possible? I want to view Solver Profiler output for a variety of Simulink simulations, and currently I am running them one by one in the Solver Profiler window to achieve this. I would like to batch run them overnight and view profiler results afterwards, is this possible? simulink profiler, command line MATLAB Answers — New Questions
Allocating parameters to ramfuncs section
I need to execute parts of my code on the C2000 from RAM. I was able to generate code from my subsystem into a non‑reusable, standalone function and copy that function to RAM. I also need to copy some of the parameters used by this function into RAM so they can execute more quickly.
Paragraph 7 of the following document attempts to describe the process, but it does not provide enough detail to follow:
Load Data/Code to Flash and Run from RAM on TI C2000 – MATLAB & Simulink
Could you provide guidance and a step‑by‑step explanation of how to perform this operation?I need to execute parts of my code on the C2000 from RAM. I was able to generate code from my subsystem into a non‑reusable, standalone function and copy that function to RAM. I also need to copy some of the parameters used by this function into RAM so they can execute more quickly.
Paragraph 7 of the following document attempts to describe the process, but it does not provide enough detail to follow:
Load Data/Code to Flash and Run from RAM on TI C2000 – MATLAB & Simulink
Could you provide guidance and a step‑by‑step explanation of how to perform this operation? I need to execute parts of my code on the C2000 from RAM. I was able to generate code from my subsystem into a non‑reusable, standalone function and copy that function to RAM. I also need to copy some of the parameters used by this function into RAM so they can execute more quickly.
Paragraph 7 of the following document attempts to describe the process, but it does not provide enough detail to follow:
Load Data/Code to Flash and Run from RAM on TI C2000 – MATLAB & Simulink
Could you provide guidance and a step‑by‑step explanation of how to perform this operation? c2000, simulink MATLAB Answers — New Questions
Is it possible to switch MATLAB versions after launching via the MATLAB .NET Engine API?
I want to launch MATLAB via the .NET Engine API from a C# application to run my Simulink models. My Simulink models are created using a variety of MATLAB versions (e.g., R2023b and R2025b). Can my C# application launch an instance of R2023b using the MATLAB .NET Engine API, perform some processing, close R2023b, and then launch an R2025b instance?I want to launch MATLAB via the .NET Engine API from a C# application to run my Simulink models. My Simulink models are created using a variety of MATLAB versions (e.g., R2023b and R2025b). Can my C# application launch an instance of R2023b using the MATLAB .NET Engine API, perform some processing, close R2023b, and then launch an R2025b instance? I want to launch MATLAB via the .NET Engine API from a C# application to run my Simulink models. My Simulink models are created using a variety of MATLAB versions (e.g., R2023b and R2025b). Can my C# application launch an instance of R2023b using the MATLAB .NET Engine API, perform some processing, close R2023b, and then launch an R2025b instance? .net, c#, engine, api, multiple, multi MATLAB Answers — New Questions
unrecognized date format from “dir” command for french users with july month
Hi Guys,
I have 2024b version and encountered a bug that was not here on previous version.
dir command generates a date (last modification on the file) for any file like ’26-sept.-2018 16:52:18′
then when using datenum or datevec on this output, it returns a correct date transformation.
However when the date includes month of july like this:
’17-juil.-2023 10:29:58′ (french abbreviation for july month)
datenum could not recognized this entry as a valid date.
Error message is:
Error using datenum (line 200)
Failed to convert input to date numbers.
Caused by:
Unable to perform assignment because the left and right sides have a different number of elements.
it works well for every french abbreviation of all months except for july.Hi Guys,
I have 2024b version and encountered a bug that was not here on previous version.
dir command generates a date (last modification on the file) for any file like ’26-sept.-2018 16:52:18′
then when using datenum or datevec on this output, it returns a correct date transformation.
However when the date includes month of july like this:
’17-juil.-2023 10:29:58′ (french abbreviation for july month)
datenum could not recognized this entry as a valid date.
Error message is:
Error using datenum (line 200)
Failed to convert input to date numbers.
Caused by:
Unable to perform assignment because the left and right sides have a different number of elements.
it works well for every french abbreviation of all months except for july. Hi Guys,
I have 2024b version and encountered a bug that was not here on previous version.
dir command generates a date (last modification on the file) for any file like ’26-sept.-2018 16:52:18′
then when using datenum or datevec on this output, it returns a correct date transformation.
However when the date includes month of july like this:
’17-juil.-2023 10:29:58′ (french abbreviation for july month)
datenum could not recognized this entry as a valid date.
Error message is:
Error using datenum (line 200)
Failed to convert input to date numbers.
Caused by:
Unable to perform assignment because the left and right sides have a different number of elements.
it works well for every french abbreviation of all months except for july. date format MATLAB Answers — New Questions
listdlg in MATLAB R2025b returns selected indices in click order instead of ascending order
In MATLAB R2025b, listdlg appears to return the selected indices in the order the user clicked them, rather than in ascending numeric order.
In older versions such as R2022b and R2024a, the returned indices were ordered ascendingly, which made the behavior predictable and easy to work with in downstream code.
This change caused nasty bugs in existing code on my side, because I use the returned indices to index into related lists that assume a consistent ascending order. With the new behavior, the item order can differ depending on click sequence, which breaks code that previously worked correctly.
Minimal example:
[idx, tf] = listdlg( …
‘ListString’, {‘A’,’B’,’C’,’D’,’E’}, …
‘SelectionMode’, ‘multiple’);
disp(idx)
In R2025b, if I click items in the order 2, 1, 3, the result is: [2 1 3] -> Which leads to calling [‘B’, ‘A’, ‘C’] in downstream code
Whereas in older releases it was always: [1 2 3]
Questions:
Is this behavior change intentional in R2025b? I cannot find any documentation on that.
Is there a way to restore the old ascending-order behavior globally, for example via a preference or in startup.m?
Or is the only safe solution now to wrap every listdlg call with sort(idx) manually?
I can work around this with sort, but it would be very helpful if there were a default compatibility option, especially for larger existing codebases.In MATLAB R2025b, listdlg appears to return the selected indices in the order the user clicked them, rather than in ascending numeric order.
In older versions such as R2022b and R2024a, the returned indices were ordered ascendingly, which made the behavior predictable and easy to work with in downstream code.
This change caused nasty bugs in existing code on my side, because I use the returned indices to index into related lists that assume a consistent ascending order. With the new behavior, the item order can differ depending on click sequence, which breaks code that previously worked correctly.
Minimal example:
[idx, tf] = listdlg( …
‘ListString’, {‘A’,’B’,’C’,’D’,’E’}, …
‘SelectionMode’, ‘multiple’);
disp(idx)
In R2025b, if I click items in the order 2, 1, 3, the result is: [2 1 3] -> Which leads to calling [‘B’, ‘A’, ‘C’] in downstream code
Whereas in older releases it was always: [1 2 3]
Questions:
Is this behavior change intentional in R2025b? I cannot find any documentation on that.
Is there a way to restore the old ascending-order behavior globally, for example via a preference or in startup.m?
Or is the only safe solution now to wrap every listdlg call with sort(idx) manually?
I can work around this with sort, but it would be very helpful if there were a default compatibility option, especially for larger existing codebases. In MATLAB R2025b, listdlg appears to return the selected indices in the order the user clicked them, rather than in ascending numeric order.
In older versions such as R2022b and R2024a, the returned indices were ordered ascendingly, which made the behavior predictable and easy to work with in downstream code.
This change caused nasty bugs in existing code on my side, because I use the returned indices to index into related lists that assume a consistent ascending order. With the new behavior, the item order can differ depending on click sequence, which breaks code that previously worked correctly.
Minimal example:
[idx, tf] = listdlg( …
‘ListString’, {‘A’,’B’,’C’,’D’,’E’}, …
‘SelectionMode’, ‘multiple’);
disp(idx)
In R2025b, if I click items in the order 2, 1, 3, the result is: [2 1 3] -> Which leads to calling [‘B’, ‘A’, ‘C’] in downstream code
Whereas in older releases it was always: [1 2 3]
Questions:
Is this behavior change intentional in R2025b? I cannot find any documentation on that.
Is there a way to restore the old ascending-order behavior globally, for example via a preference or in startup.m?
Or is the only safe solution now to wrap every listdlg call with sort(idx) manually?
I can work around this with sort, but it would be very helpful if there were a default compatibility option, especially for larger existing codebases. listdlg, order, click, user MATLAB Answers — New Questions
How to use the nonlinear least square fitting to fit a transfer function?How to improve the fitting accuracy
I have a dataset Y representing the real part Y(:,1) and the imaginary part (Y:,2) of a function against the frequency fq. I want to find the coefficient of the transfer function to have the a good fit with the dataset. The transfer function is given assumed to have a fifth order, (so there are totally 10 unknowns) T(p,q,s)=p(5)*s^4+p(4)*s^3+p(3)*s^2+p(2)*s+p(1))/(s^5+q(5)*s^4+q(4)*s^3+q(3)*s^2+q(2)*s+q(1));
The code is given in the attached, I split the objective function as the imaginary and real part respectively, the objective function is (real(T)-Y(:,1))^2+(imag(T)-Y(:,2)) over all the selected points in the Y-fq curve.
The blue circle is the fitted result from the NLSQ, but they are slightly away from the original data. My question is how to improve the code to improve the fitting result.
In the attached files,"nonlsqfitting.mat" is the Y and fq data; NLSFmat is the runing code; OBJrealimag.m is the objective function, where Yout(:,1) is the real part of T and Yout(:,2) is the imaginary part of T.I have a dataset Y representing the real part Y(:,1) and the imaginary part (Y:,2) of a function against the frequency fq. I want to find the coefficient of the transfer function to have the a good fit with the dataset. The transfer function is given assumed to have a fifth order, (so there are totally 10 unknowns) T(p,q,s)=p(5)*s^4+p(4)*s^3+p(3)*s^2+p(2)*s+p(1))/(s^5+q(5)*s^4+q(4)*s^3+q(3)*s^2+q(2)*s+q(1));
The code is given in the attached, I split the objective function as the imaginary and real part respectively, the objective function is (real(T)-Y(:,1))^2+(imag(T)-Y(:,2)) over all the selected points in the Y-fq curve.
The blue circle is the fitted result from the NLSQ, but they are slightly away from the original data. My question is how to improve the code to improve the fitting result.
In the attached files,"nonlsqfitting.mat" is the Y and fq data; NLSFmat is the runing code; OBJrealimag.m is the objective function, where Yout(:,1) is the real part of T and Yout(:,2) is the imaginary part of T. I have a dataset Y representing the real part Y(:,1) and the imaginary part (Y:,2) of a function against the frequency fq. I want to find the coefficient of the transfer function to have the a good fit with the dataset. The transfer function is given assumed to have a fifth order, (so there are totally 10 unknowns) T(p,q,s)=p(5)*s^4+p(4)*s^3+p(3)*s^2+p(2)*s+p(1))/(s^5+q(5)*s^4+q(4)*s^3+q(3)*s^2+q(2)*s+q(1));
The code is given in the attached, I split the objective function as the imaginary and real part respectively, the objective function is (real(T)-Y(:,1))^2+(imag(T)-Y(:,2)) over all the selected points in the Y-fq curve.
The blue circle is the fitted result from the NLSQ, but they are slightly away from the original data. My question is how to improve the code to improve the fitting result.
In the attached files,"nonlsqfitting.mat" is the Y and fq data; NLSFmat is the runing code; OBJrealimag.m is the objective function, where Yout(:,1) is the real part of T and Yout(:,2) is the imaginary part of T. nonlinear least square fitting transfer function MATLAB Answers — New Questions
Title is missing when saving a figure using print, saveas, exportgraphics, and printpreview
Context: When plotting images, I have often set the tick marks to face outward, where they are not obscured by the image. This change requires that I nudge the title upward by a small amount so that it is separated from the ticks.
Problem: When I save the file using print, saveas, exportgraphics or printpreview, the title is sometimes missing in the output file. (See attached examples above.)
I found that this problem occurs when the image is plotted using pcolor (and probably surf as well). It does not occur when using plot and imagesc. Annotation is used below to draw an outline of the outer extent of the figure. The nudged title clearly lies within that limit.
Work Around: The problem is fixed by ensuring that the Units property for the title is set to data after adjusting the title position. Note that I have filed a bug report with Matlab.
Versions: This problem did not occur with Matlab versions 2022a and earlier. It started with version 2022b and continues with version 2023a.
Coded example:
function test_figureTitleProblem
%… Simple demonstration of missing title problem.
% When plotting images, I have often set the tick marks to face outward,
% where they are not obscurved by the image. This change requires that
% I nudge the title upward by a small amount so that it is separated
% from the ticks.
%
% Problem: When I save the file using print, saveas, exportgraphics
% and printpreview, the title is missing in the output file.
% I found that this problem occurs when the image is plotted using
% pcolor, and does not occur when imagesc is used. I also found
% that the problem can be fixed by changing the Units property for the title
% back to data (see below). Annotation is used below to draw an outline of
% the outer extent of the figure. The nudged title clearly lies within
% that limit.
%% Initialize variables
%… Load Matlab’s global topographic data
load(‘topo.mat’, ‘topo’);
%… Create grid vectors
lon = 0:359;
lat = -89:90;
%% Plot
figure
%… Missing title occurs with pcolor, and not with imagesc
pcolor(lon, lat, topo)
shading interp
% imagesc(lon, lat, topo)
% axis xy
%… Format plot
hA = gca;
hA.Box = ‘on’;
hA.TickDir = ‘out’; % Oriented tick marks to face outward
hA.Layer = ‘top’; % Places grid lines and tick markers on top of image
hA.FontSize = 16;
hA.LineWidth = 1;
%… Render title, and nudge upward to separate from outward tick marks
hT = title(‘Demonstration of Demonstration of Missing Title’, ‘FontSize’, 16);
hT.Units = ‘normalized’;
hT.Position(2) = hT.Position(2) + 0.02;
% hT.Units = ‘data’; % Uncomment this line to fix problem
%… Draw rectangle to show outer limit for figure
annotation("rectangle", hA.OuterPosition, Color="red", LineWidth=1)
%… Start print preview to show that the title is missing
print(‘missingTitle_print.pdf’, ‘-dpdf’)
saveas(hA, ‘missingTitle_saveas.pdf’)
exportgraphics(hA, ‘missingTitle_exportgraphics.pdf’)
printpreview
endContext: When plotting images, I have often set the tick marks to face outward, where they are not obscured by the image. This change requires that I nudge the title upward by a small amount so that it is separated from the ticks.
Problem: When I save the file using print, saveas, exportgraphics or printpreview, the title is sometimes missing in the output file. (See attached examples above.)
I found that this problem occurs when the image is plotted using pcolor (and probably surf as well). It does not occur when using plot and imagesc. Annotation is used below to draw an outline of the outer extent of the figure. The nudged title clearly lies within that limit.
Work Around: The problem is fixed by ensuring that the Units property for the title is set to data after adjusting the title position. Note that I have filed a bug report with Matlab.
Versions: This problem did not occur with Matlab versions 2022a and earlier. It started with version 2022b and continues with version 2023a.
Coded example:
function test_figureTitleProblem
%… Simple demonstration of missing title problem.
% When plotting images, I have often set the tick marks to face outward,
% where they are not obscurved by the image. This change requires that
% I nudge the title upward by a small amount so that it is separated
% from the ticks.
%
% Problem: When I save the file using print, saveas, exportgraphics
% and printpreview, the title is missing in the output file.
% I found that this problem occurs when the image is plotted using
% pcolor, and does not occur when imagesc is used. I also found
% that the problem can be fixed by changing the Units property for the title
% back to data (see below). Annotation is used below to draw an outline of
% the outer extent of the figure. The nudged title clearly lies within
% that limit.
%% Initialize variables
%… Load Matlab’s global topographic data
load(‘topo.mat’, ‘topo’);
%… Create grid vectors
lon = 0:359;
lat = -89:90;
%% Plot
figure
%… Missing title occurs with pcolor, and not with imagesc
pcolor(lon, lat, topo)
shading interp
% imagesc(lon, lat, topo)
% axis xy
%… Format plot
hA = gca;
hA.Box = ‘on’;
hA.TickDir = ‘out’; % Oriented tick marks to face outward
hA.Layer = ‘top’; % Places grid lines and tick markers on top of image
hA.FontSize = 16;
hA.LineWidth = 1;
%… Render title, and nudge upward to separate from outward tick marks
hT = title(‘Demonstration of Demonstration of Missing Title’, ‘FontSize’, 16);
hT.Units = ‘normalized’;
hT.Position(2) = hT.Position(2) + 0.02;
% hT.Units = ‘data’; % Uncomment this line to fix problem
%… Draw rectangle to show outer limit for figure
annotation("rectangle", hA.OuterPosition, Color="red", LineWidth=1)
%… Start print preview to show that the title is missing
print(‘missingTitle_print.pdf’, ‘-dpdf’)
saveas(hA, ‘missingTitle_saveas.pdf’)
exportgraphics(hA, ‘missingTitle_exportgraphics.pdf’)
printpreview
end Context: When plotting images, I have often set the tick marks to face outward, where they are not obscured by the image. This change requires that I nudge the title upward by a small amount so that it is separated from the ticks.
Problem: When I save the file using print, saveas, exportgraphics or printpreview, the title is sometimes missing in the output file. (See attached examples above.)
I found that this problem occurs when the image is plotted using pcolor (and probably surf as well). It does not occur when using plot and imagesc. Annotation is used below to draw an outline of the outer extent of the figure. The nudged title clearly lies within that limit.
Work Around: The problem is fixed by ensuring that the Units property for the title is set to data after adjusting the title position. Note that I have filed a bug report with Matlab.
Versions: This problem did not occur with Matlab versions 2022a and earlier. It started with version 2022b and continues with version 2023a.
Coded example:
function test_figureTitleProblem
%… Simple demonstration of missing title problem.
% When plotting images, I have often set the tick marks to face outward,
% where they are not obscurved by the image. This change requires that
% I nudge the title upward by a small amount so that it is separated
% from the ticks.
%
% Problem: When I save the file using print, saveas, exportgraphics
% and printpreview, the title is missing in the output file.
% I found that this problem occurs when the image is plotted using
% pcolor, and does not occur when imagesc is used. I also found
% that the problem can be fixed by changing the Units property for the title
% back to data (see below). Annotation is used below to draw an outline of
% the outer extent of the figure. The nudged title clearly lies within
% that limit.
%% Initialize variables
%… Load Matlab’s global topographic data
load(‘topo.mat’, ‘topo’);
%… Create grid vectors
lon = 0:359;
lat = -89:90;
%% Plot
figure
%… Missing title occurs with pcolor, and not with imagesc
pcolor(lon, lat, topo)
shading interp
% imagesc(lon, lat, topo)
% axis xy
%… Format plot
hA = gca;
hA.Box = ‘on’;
hA.TickDir = ‘out’; % Oriented tick marks to face outward
hA.Layer = ‘top’; % Places grid lines and tick markers on top of image
hA.FontSize = 16;
hA.LineWidth = 1;
%… Render title, and nudge upward to separate from outward tick marks
hT = title(‘Demonstration of Demonstration of Missing Title’, ‘FontSize’, 16);
hT.Units = ‘normalized’;
hT.Position(2) = hT.Position(2) + 0.02;
% hT.Units = ‘data’; % Uncomment this line to fix problem
%… Draw rectangle to show outer limit for figure
annotation("rectangle", hA.OuterPosition, Color="red", LineWidth=1)
%… Start print preview to show that the title is missing
print(‘missingTitle_print.pdf’, ‘-dpdf’)
saveas(hA, ‘missingTitle_saveas.pdf’)
exportgraphics(hA, ‘missingTitle_exportgraphics.pdf’)
printpreview
end missing title MATLAB Answers — New Questions
Why am I receiving errors when reading and writing to an instrument with Instrument Control Toolbox R2024b?
I am connecting to my Windows 11 based Keysight oscilloscope and source via "visadev." I intermittently receive the following two errors when reading and writing to the instruments using "fscanf" and "fprintf":
Error using matlabshared.transportlib.internal.compatibility.LegacyASCIIMixin/fprintf (line 140)
Error writing String.
Error writing data to the transport.
Adaptor command ‘write’ failed with status code: -550.
Error using matlabshared.transportlib.internal.compatibility.LegacyASCIIMixin/fscanf (line 305)
Failed to read data from the instrument due to a driver error.
These errors occur seemingly at random, and a similar error occurs when using the function "visa" instead of "visadev":
Error using icinterface/fprintf (line 158)
VISA: The IO connection for the session has been lost
Why do these errors occur and how can I prevent them?I am connecting to my Windows 11 based Keysight oscilloscope and source via "visadev." I intermittently receive the following two errors when reading and writing to the instruments using "fscanf" and "fprintf":
Error using matlabshared.transportlib.internal.compatibility.LegacyASCIIMixin/fprintf (line 140)
Error writing String.
Error writing data to the transport.
Adaptor command ‘write’ failed with status code: -550.
Error using matlabshared.transportlib.internal.compatibility.LegacyASCIIMixin/fscanf (line 305)
Failed to read data from the instrument due to a driver error.
These errors occur seemingly at random, and a similar error occurs when using the function "visa" instead of "visadev":
Error using icinterface/fprintf (line 158)
VISA: The IO connection for the session has been lost
Why do these errors occur and how can I prevent them? I am connecting to my Windows 11 based Keysight oscilloscope and source via "visadev." I intermittently receive the following two errors when reading and writing to the instruments using "fscanf" and "fprintf":
Error using matlabshared.transportlib.internal.compatibility.LegacyASCIIMixin/fprintf (line 140)
Error writing String.
Error writing data to the transport.
Adaptor command ‘write’ failed with status code: -550.
Error using matlabshared.transportlib.internal.compatibility.LegacyASCIIMixin/fscanf (line 305)
Failed to read data from the instrument due to a driver error.
These errors occur seemingly at random, and a similar error occurs when using the function "visa" instead of "visadev":
Error using icinterface/fprintf (line 158)
VISA: The IO connection for the session has been lost
Why do these errors occur and how can I prevent them? fprintf, fscanf, instrumentcontroltoolbox, write, read MATLAB Answers — New Questions
How do I compute bandpower?
Which parts of this code is correct? I’m getting confused on which sections are relevant for my question above?
N = length(sig1);
xdft1 = fft(sig1);
xdft1 = xdft1(1:N/2+1);
psdx1 = (1/(Fs*N)) * abs(xdft1).^2;
psdx1(2:end-1) = 2*psdx1(2:end-1);
freq1 = 0:Fs/length(sig1):Fs/2;
P1_band = psdx1(freq1 >= 20 & freq1 <= 100);
f1_band = freq1(freq1 >= 20 & freq1 <= 100);
power_sig1 = trapz(f1_band, P1_band);
noise = x_new – x_notch;
SNR_dB = snr(x_notch, noise);
P_signal = mean(signalSeg.^2, ‘omitnan’);
P_noise = mean(noiseSeg.^2, ‘omitnan’);
SNR_dB = 10*log10(P_signal / P_noise);
f_notch = 60;
BW_notch = 2;
wo = f_notch/(Fs/2);
Q = f_notch/BW_notch;
bw = wo/Q;
[b_n,a_n] = iirnotch(wo,bw);
x_notch = filtfilt(b_n,a_n,x_bp);
x = x(:);
t = (0:length(x)-1)’/Fs;
% Frequency analysis
x_dm = x – mean(x);
N = length(x_dm);
X = fft(x_dm);
K = floor(N/2);
X = X(1:K+1);
PSD = (1/(Fs*N)) * abs(X).^2;
if K > 1
PSD(2:end-1) = 2*PSD(2:end-1);
end
f = (0:K)’ * (Fs/N);
% Find dominant frequency
[~, idxPeak] = max(PSD(2:end)); % ignore 0 Hz
idxPeak = idxPeak + 1;
domFreq = f(idxPeak);
fprintf(‘Dominant frequency = %.2f Hzn’, domFreq);Which parts of this code is correct? I’m getting confused on which sections are relevant for my question above?
N = length(sig1);
xdft1 = fft(sig1);
xdft1 = xdft1(1:N/2+1);
psdx1 = (1/(Fs*N)) * abs(xdft1).^2;
psdx1(2:end-1) = 2*psdx1(2:end-1);
freq1 = 0:Fs/length(sig1):Fs/2;
P1_band = psdx1(freq1 >= 20 & freq1 <= 100);
f1_band = freq1(freq1 >= 20 & freq1 <= 100);
power_sig1 = trapz(f1_band, P1_band);
noise = x_new – x_notch;
SNR_dB = snr(x_notch, noise);
P_signal = mean(signalSeg.^2, ‘omitnan’);
P_noise = mean(noiseSeg.^2, ‘omitnan’);
SNR_dB = 10*log10(P_signal / P_noise);
f_notch = 60;
BW_notch = 2;
wo = f_notch/(Fs/2);
Q = f_notch/BW_notch;
bw = wo/Q;
[b_n,a_n] = iirnotch(wo,bw);
x_notch = filtfilt(b_n,a_n,x_bp);
x = x(:);
t = (0:length(x)-1)’/Fs;
% Frequency analysis
x_dm = x – mean(x);
N = length(x_dm);
X = fft(x_dm);
K = floor(N/2);
X = X(1:K+1);
PSD = (1/(Fs*N)) * abs(X).^2;
if K > 1
PSD(2:end-1) = 2*PSD(2:end-1);
end
f = (0:K)’ * (Fs/N);
% Find dominant frequency
[~, idxPeak] = max(PSD(2:end)); % ignore 0 Hz
idxPeak = idxPeak + 1;
domFreq = f(idxPeak);
fprintf(‘Dominant frequency = %.2f Hzn’, domFreq); Which parts of this code is correct? I’m getting confused on which sections are relevant for my question above?
N = length(sig1);
xdft1 = fft(sig1);
xdft1 = xdft1(1:N/2+1);
psdx1 = (1/(Fs*N)) * abs(xdft1).^2;
psdx1(2:end-1) = 2*psdx1(2:end-1);
freq1 = 0:Fs/length(sig1):Fs/2;
P1_band = psdx1(freq1 >= 20 & freq1 <= 100);
f1_band = freq1(freq1 >= 20 & freq1 <= 100);
power_sig1 = trapz(f1_band, P1_band);
noise = x_new – x_notch;
SNR_dB = snr(x_notch, noise);
P_signal = mean(signalSeg.^2, ‘omitnan’);
P_noise = mean(noiseSeg.^2, ‘omitnan’);
SNR_dB = 10*log10(P_signal / P_noise);
f_notch = 60;
BW_notch = 2;
wo = f_notch/(Fs/2);
Q = f_notch/BW_notch;
bw = wo/Q;
[b_n,a_n] = iirnotch(wo,bw);
x_notch = filtfilt(b_n,a_n,x_bp);
x = x(:);
t = (0:length(x)-1)’/Fs;
% Frequency analysis
x_dm = x – mean(x);
N = length(x_dm);
X = fft(x_dm);
K = floor(N/2);
X = X(1:K+1);
PSD = (1/(Fs*N)) * abs(X).^2;
if K > 1
PSD(2:end-1) = 2*PSD(2:end-1);
end
f = (0:K)’ * (Fs/N);
% Find dominant frequency
[~, idxPeak] = max(PSD(2:end)); % ignore 0 Hz
idxPeak = idxPeak + 1;
domFreq = f(idxPeak);
fprintf(‘Dominant frequency = %.2f Hzn’, domFreq); bandpower MATLAB Answers — New Questions
Need to download MATLAB 2008b onto my existing computer but no more activations exist for my license
My company (MITRE) has implemented CyberArk security that prevents me from accessing MATLAB on my C: drive. I needed to transfer MATLAB over to my personal folder but inorder to do this, I had to uninstall MATLAB. Unfortunately, when I try to reinstall MATLAB 2008b, it says I have no further activations on the license. This is the same computer that I have been using — I have not changed computers. I needed a similar license refresh a couple of years ago when a security breach resulted in scrubing the disk, prompting me to reinstall all of my former software including MATLAB. Please advise — I really rely on this software for my work.
Thank youMy company (MITRE) has implemented CyberArk security that prevents me from accessing MATLAB on my C: drive. I needed to transfer MATLAB over to my personal folder but inorder to do this, I had to uninstall MATLAB. Unfortunately, when I try to reinstall MATLAB 2008b, it says I have no further activations on the license. This is the same computer that I have been using — I have not changed computers. I needed a similar license refresh a couple of years ago when a security breach resulted in scrubing the disk, prompting me to reinstall all of my former software including MATLAB. Please advise — I really rely on this software for my work.
Thank you My company (MITRE) has implemented CyberArk security that prevents me from accessing MATLAB on my C: drive. I needed to transfer MATLAB over to my personal folder but inorder to do this, I had to uninstall MATLAB. Unfortunately, when I try to reinstall MATLAB 2008b, it says I have no further activations on the license. This is the same computer that I have been using — I have not changed computers. I needed a similar license refresh a couple of years ago when a security breach resulted in scrubing the disk, prompting me to reinstall all of my former software including MATLAB. Please advise — I really rely on this software for my work.
Thank you license activation MATLAB Answers — New Questions
proper IFFT procedure for converting S-params into time domain reflectometry
Basic discontinuety was simulated 0Hz to 40Ghz 40000 samples as presented in the photos . S-parameters were extracted as S2P file(attached in the link). My goal is to see the discontinuety using time domain reflectometry. what is the proper way to do IFFT in this case? What windows should I multiply with? Thanks.Basic discontinuety was simulated 0Hz to 40Ghz 40000 samples as presented in the photos . S-parameters were extracted as S2P file(attached in the link). My goal is to see the discontinuety using time domain reflectometry. what is the proper way to do IFFT in this case? What windows should I multiply with? Thanks. Basic discontinuety was simulated 0Hz to 40Ghz 40000 samples as presented in the photos . S-parameters were extracted as S2P file(attached in the link). My goal is to see the discontinuety using time domain reflectometry. what is the proper way to do IFFT in this case? What windows should I multiply with? Thanks. ifft, tdr, s-parameters MATLAB Answers — New Questions
Why Does polyval Return Zero When the Coefficients are Empty?
polyval([],1)
polyval(ones(1,0),1)
Do those results follow from a mathematical justification or are they arbitrarily specified?polyval([],1)
polyval(ones(1,0),1)
Do those results follow from a mathematical justification or are they arbitrarily specified? polyval([],1)
polyval(ones(1,0),1)
Do those results follow from a mathematical justification or are they arbitrarily specified? polynomial, empty coefficients MATLAB Answers — New Questions
I want to decrease the time my Script
Elapsed time is 8.597842 seconds.
clear, clc
tic
load(‘Erros_a.mat’); load(‘Sp1_b.mat’);
Relatorio = zeros(5000,4,’uint32′);
Relatorio_final = zeros(10000,4,’uint32′);
a = 10;
for i1 = 1:1
% BLOCO 1 — usa cache se existir, senão gera e salva
cache_file = sprintf(‘Erros_b_cache_%d.mat’, i1);
if exist(cache_file, ‘file’)
load(cache_file);
else
linha_a = Erros_a(a,:);
vals = linha_a(linha_a > 0);
vals = vals(1:end-2);
nRef = numel(vals);
cols_b1 = 2*(double(vals)-1) + 1;
cols_b2 = 2*(double(vals)-1) + 2;
passa = (Sp1_b(:, cols_b1) == 0) & (Sp1_b(:, cols_b2) == 0);
col_dest_matrix = uint32(cumsum(passa, 2) – passa + 1);
Erros_b = zeros(3268760, 37, ‘uint32’);
for d = 1:nRef
linhas_ok = find(passa(:, d));
if ~isempty(linhas_ok)
idx = sub2ind([3268760, 37], linhas_ok, double(col_dest_matrix(linhas_ok, d)));
Erros_b(idx) = vals(d);
end
end
save(cache_file, ‘Erros_b’, ‘-v7.3’);
end
% BLOCO 2 — preparação
load(‘Sp1_c.mat’);
Erros_b(:,38) = (1:size(Erros_b,1))’;
mascara = Erros_b(:, 13) > 50;
Erros_reduzido = Erros_b(mascara, :);
[lin_u, col_u] = find(Sp1_c == 1);
uns_nas_colunas = accumarray(col_u, lin_u, [size(Sp1_c,2) 1], @(x){sort(x)}, {[]});
clear Erros_b Sp1_c lin_u col_u mascara;
[~, ordem] = sortrows(Erros_reduzido(:, 1:38));
Erros_reduzido_ordem = Erros_reduzido(ordem, :);
[~, ordem] = sortrows(Erros_reduzido_ordem(:, 1:38));
Erros_reduzido_ordem = Erros_reduzido_ordem(ordem, :);
clear Erros_reduzido ordem;
ERO = double(Erros_reduzido_ordem);
clear Erros_reduzido_ordem;
nCols_c = numel(uns_nas_colunas);
uns_sets = cell(nCols_c, 1);
for cc = 1:nCols_c
s = uns_nas_colunas{cc};
if ~isempty(s)
m = false(max(s), 1);
m(s) = true;
uns_sets{cc} = m;
else
uns_sets{cc} = false(0,1);
end
end
% BLOCO 3 — while principal
num_linhas = size(ERO, 1);
y = 1;
offset = 0;
while (offset + 1) <= num_linhas
i = offset + 1;
linha_at = ERO(i, 1:38);
a_valid = linha_at(linha_at > 0 & linha_at <= 100);
% k=2: dois ponteiros
A = uns_nas_colunas{a_valid(1)};
B = uns_nas_colunas{a_valid(2)};
buf = zeros(min(numel(A), numel(B)), 1);
ia = 1; ib = 1; ic = 0;
na = numel(A); nb = numel(B);
while ia <= na && ib <= nb
if A(ia) == B(ib)
ic = ic + 1; buf(ic) = A(ia);
ia = ia + 1; ib = ib + 1;
elseif A(ia) < B(ib); ia = ia + 1;
else; ib = ib + 1;
end
end
candidatas = buf(1:ic);
w=1; z=1;
n(w,1) = a_valid(w,1);
achou = false;
if isempty(candidatas)
melhor_erro = a_valid(2) – 1;
melhor_linha = linha_at(38);
n(w,2) = a_valid(w,2);
nP = length(n);
lo = offset + 1; hi = num_linhas; ultlin_abs = offset;
if all(ERO(lo, 1:nP) == n)
while lo <= hi
mid = floor((lo + hi) / 2);
if all(ERO(mid, 1:nP) == n)
ultlin_abs = mid; lo = mid + 1;
else; hi = mid – 1; end
end
end
if ultlin_abs > offset; offset = ultlin_abs;
else; offset = offset + 1; end
n = [];
Relatorio(y,1) = Erros_a(i1,40);
Relatorio(y,2) = A(1);
Relatorio(y,3) = melhor_linha;
Relatorio(y,4) = melhor_erro;
y = y + 1;
achou = true;
end
% k>=3: lookup lógico
for k = 3:length(a_valid)
if achou; break; end
n(w,k-1) = a_valid(w,k-1);
col_atual = a_valid(k);
s2 = uns_sets{col_atual};
if isempty(candidatas) || isempty(s2)
proximas = [];
else
mask = candidatas <= numel(s2);
cand_validas = candidatas(mask);
if isempty(cand_validas); proximas = [];
else; proximas = cand_validas(s2(cand_validas)); end
end
if isempty(proximas)
melhor_erro = col_atual – 1;
melhor_linha = linha_at(38);
n(w,k) = a_valid(w,k);
nP = length(n);
lo = offset + 1; hi = num_linhas; ultlin_abs = offset;
if all(ERO(lo, 1:nP) == n)
while lo <= hi
mid = floor((lo + hi) / 2);
if all(ERO(mid, 1:nP) == n)
ultlin_abs = mid; lo = mid + 1;
else; hi = mid – 1; end
end
end
if ultlin_abs > offset; offset = ultlin_abs;
else; offset = offset + 1; end
n = [];
Relatorio(y,1) = Erros_a(i1,40);
Relatorio(y,2) = candidatas(1);
Relatorio(y,3) = melhor_linha;
Relatorio(y,4) = melhor_erro;
y = y + 1;
achou = true;
break;
end
candidatas = proximas;
melhor_linha = candidatas(1);
end % for k
if ~achou; offset = offset + 1; end
end % while
clear ERO uns_sets;
Relatorio = sortrows(Relatorio, 4, ‘descend’);
Relatorio_final(i1,:) = Relatorio(1,:);
Relatorio(:,:) = 0;
a = a + 1;
end % i1
tocElapsed time is 8.597842 seconds.
clear, clc
tic
load(‘Erros_a.mat’); load(‘Sp1_b.mat’);
Relatorio = zeros(5000,4,’uint32′);
Relatorio_final = zeros(10000,4,’uint32′);
a = 10;
for i1 = 1:1
% BLOCO 1 — usa cache se existir, senão gera e salva
cache_file = sprintf(‘Erros_b_cache_%d.mat’, i1);
if exist(cache_file, ‘file’)
load(cache_file);
else
linha_a = Erros_a(a,:);
vals = linha_a(linha_a > 0);
vals = vals(1:end-2);
nRef = numel(vals);
cols_b1 = 2*(double(vals)-1) + 1;
cols_b2 = 2*(double(vals)-1) + 2;
passa = (Sp1_b(:, cols_b1) == 0) & (Sp1_b(:, cols_b2) == 0);
col_dest_matrix = uint32(cumsum(passa, 2) – passa + 1);
Erros_b = zeros(3268760, 37, ‘uint32’);
for d = 1:nRef
linhas_ok = find(passa(:, d));
if ~isempty(linhas_ok)
idx = sub2ind([3268760, 37], linhas_ok, double(col_dest_matrix(linhas_ok, d)));
Erros_b(idx) = vals(d);
end
end
save(cache_file, ‘Erros_b’, ‘-v7.3’);
end
% BLOCO 2 — preparação
load(‘Sp1_c.mat’);
Erros_b(:,38) = (1:size(Erros_b,1))’;
mascara = Erros_b(:, 13) > 50;
Erros_reduzido = Erros_b(mascara, :);
[lin_u, col_u] = find(Sp1_c == 1);
uns_nas_colunas = accumarray(col_u, lin_u, [size(Sp1_c,2) 1], @(x){sort(x)}, {[]});
clear Erros_b Sp1_c lin_u col_u mascara;
[~, ordem] = sortrows(Erros_reduzido(:, 1:38));
Erros_reduzido_ordem = Erros_reduzido(ordem, :);
[~, ordem] = sortrows(Erros_reduzido_ordem(:, 1:38));
Erros_reduzido_ordem = Erros_reduzido_ordem(ordem, :);
clear Erros_reduzido ordem;
ERO = double(Erros_reduzido_ordem);
clear Erros_reduzido_ordem;
nCols_c = numel(uns_nas_colunas);
uns_sets = cell(nCols_c, 1);
for cc = 1:nCols_c
s = uns_nas_colunas{cc};
if ~isempty(s)
m = false(max(s), 1);
m(s) = true;
uns_sets{cc} = m;
else
uns_sets{cc} = false(0,1);
end
end
% BLOCO 3 — while principal
num_linhas = size(ERO, 1);
y = 1;
offset = 0;
while (offset + 1) <= num_linhas
i = offset + 1;
linha_at = ERO(i, 1:38);
a_valid = linha_at(linha_at > 0 & linha_at <= 100);
% k=2: dois ponteiros
A = uns_nas_colunas{a_valid(1)};
B = uns_nas_colunas{a_valid(2)};
buf = zeros(min(numel(A), numel(B)), 1);
ia = 1; ib = 1; ic = 0;
na = numel(A); nb = numel(B);
while ia <= na && ib <= nb
if A(ia) == B(ib)
ic = ic + 1; buf(ic) = A(ia);
ia = ia + 1; ib = ib + 1;
elseif A(ia) < B(ib); ia = ia + 1;
else; ib = ib + 1;
end
end
candidatas = buf(1:ic);
w=1; z=1;
n(w,1) = a_valid(w,1);
achou = false;
if isempty(candidatas)
melhor_erro = a_valid(2) – 1;
melhor_linha = linha_at(38);
n(w,2) = a_valid(w,2);
nP = length(n);
lo = offset + 1; hi = num_linhas; ultlin_abs = offset;
if all(ERO(lo, 1:nP) == n)
while lo <= hi
mid = floor((lo + hi) / 2);
if all(ERO(mid, 1:nP) == n)
ultlin_abs = mid; lo = mid + 1;
else; hi = mid – 1; end
end
end
if ultlin_abs > offset; offset = ultlin_abs;
else; offset = offset + 1; end
n = [];
Relatorio(y,1) = Erros_a(i1,40);
Relatorio(y,2) = A(1);
Relatorio(y,3) = melhor_linha;
Relatorio(y,4) = melhor_erro;
y = y + 1;
achou = true;
end
% k>=3: lookup lógico
for k = 3:length(a_valid)
if achou; break; end
n(w,k-1) = a_valid(w,k-1);
col_atual = a_valid(k);
s2 = uns_sets{col_atual};
if isempty(candidatas) || isempty(s2)
proximas = [];
else
mask = candidatas <= numel(s2);
cand_validas = candidatas(mask);
if isempty(cand_validas); proximas = [];
else; proximas = cand_validas(s2(cand_validas)); end
end
if isempty(proximas)
melhor_erro = col_atual – 1;
melhor_linha = linha_at(38);
n(w,k) = a_valid(w,k);
nP = length(n);
lo = offset + 1; hi = num_linhas; ultlin_abs = offset;
if all(ERO(lo, 1:nP) == n)
while lo <= hi
mid = floor((lo + hi) / 2);
if all(ERO(mid, 1:nP) == n)
ultlin_abs = mid; lo = mid + 1;
else; hi = mid – 1; end
end
end
if ultlin_abs > offset; offset = ultlin_abs;
else; offset = offset + 1; end
n = [];
Relatorio(y,1) = Erros_a(i1,40);
Relatorio(y,2) = candidatas(1);
Relatorio(y,3) = melhor_linha;
Relatorio(y,4) = melhor_erro;
y = y + 1;
achou = true;
break;
end
candidatas = proximas;
melhor_linha = candidatas(1);
end % for k
if ~achou; offset = offset + 1; end
end % while
clear ERO uns_sets;
Relatorio = sortrows(Relatorio, 4, ‘descend’);
Relatorio_final(i1,:) = Relatorio(1,:);
Relatorio(:,:) = 0;
a = a + 1;
end % i1
toc Elapsed time is 8.597842 seconds.
clear, clc
tic
load(‘Erros_a.mat’); load(‘Sp1_b.mat’);
Relatorio = zeros(5000,4,’uint32′);
Relatorio_final = zeros(10000,4,’uint32′);
a = 10;
for i1 = 1:1
% BLOCO 1 — usa cache se existir, senão gera e salva
cache_file = sprintf(‘Erros_b_cache_%d.mat’, i1);
if exist(cache_file, ‘file’)
load(cache_file);
else
linha_a = Erros_a(a,:);
vals = linha_a(linha_a > 0);
vals = vals(1:end-2);
nRef = numel(vals);
cols_b1 = 2*(double(vals)-1) + 1;
cols_b2 = 2*(double(vals)-1) + 2;
passa = (Sp1_b(:, cols_b1) == 0) & (Sp1_b(:, cols_b2) == 0);
col_dest_matrix = uint32(cumsum(passa, 2) – passa + 1);
Erros_b = zeros(3268760, 37, ‘uint32’);
for d = 1:nRef
linhas_ok = find(passa(:, d));
if ~isempty(linhas_ok)
idx = sub2ind([3268760, 37], linhas_ok, double(col_dest_matrix(linhas_ok, d)));
Erros_b(idx) = vals(d);
end
end
save(cache_file, ‘Erros_b’, ‘-v7.3’);
end
% BLOCO 2 — preparação
load(‘Sp1_c.mat’);
Erros_b(:,38) = (1:size(Erros_b,1))’;
mascara = Erros_b(:, 13) > 50;
Erros_reduzido = Erros_b(mascara, :);
[lin_u, col_u] = find(Sp1_c == 1);
uns_nas_colunas = accumarray(col_u, lin_u, [size(Sp1_c,2) 1], @(x){sort(x)}, {[]});
clear Erros_b Sp1_c lin_u col_u mascara;
[~, ordem] = sortrows(Erros_reduzido(:, 1:38));
Erros_reduzido_ordem = Erros_reduzido(ordem, :);
[~, ordem] = sortrows(Erros_reduzido_ordem(:, 1:38));
Erros_reduzido_ordem = Erros_reduzido_ordem(ordem, :);
clear Erros_reduzido ordem;
ERO = double(Erros_reduzido_ordem);
clear Erros_reduzido_ordem;
nCols_c = numel(uns_nas_colunas);
uns_sets = cell(nCols_c, 1);
for cc = 1:nCols_c
s = uns_nas_colunas{cc};
if ~isempty(s)
m = false(max(s), 1);
m(s) = true;
uns_sets{cc} = m;
else
uns_sets{cc} = false(0,1);
end
end
% BLOCO 3 — while principal
num_linhas = size(ERO, 1);
y = 1;
offset = 0;
while (offset + 1) <= num_linhas
i = offset + 1;
linha_at = ERO(i, 1:38);
a_valid = linha_at(linha_at > 0 & linha_at <= 100);
% k=2: dois ponteiros
A = uns_nas_colunas{a_valid(1)};
B = uns_nas_colunas{a_valid(2)};
buf = zeros(min(numel(A), numel(B)), 1);
ia = 1; ib = 1; ic = 0;
na = numel(A); nb = numel(B);
while ia <= na && ib <= nb
if A(ia) == B(ib)
ic = ic + 1; buf(ic) = A(ia);
ia = ia + 1; ib = ib + 1;
elseif A(ia) < B(ib); ia = ia + 1;
else; ib = ib + 1;
end
end
candidatas = buf(1:ic);
w=1; z=1;
n(w,1) = a_valid(w,1);
achou = false;
if isempty(candidatas)
melhor_erro = a_valid(2) – 1;
melhor_linha = linha_at(38);
n(w,2) = a_valid(w,2);
nP = length(n);
lo = offset + 1; hi = num_linhas; ultlin_abs = offset;
if all(ERO(lo, 1:nP) == n)
while lo <= hi
mid = floor((lo + hi) / 2);
if all(ERO(mid, 1:nP) == n)
ultlin_abs = mid; lo = mid + 1;
else; hi = mid – 1; end
end
end
if ultlin_abs > offset; offset = ultlin_abs;
else; offset = offset + 1; end
n = [];
Relatorio(y,1) = Erros_a(i1,40);
Relatorio(y,2) = A(1);
Relatorio(y,3) = melhor_linha;
Relatorio(y,4) = melhor_erro;
y = y + 1;
achou = true;
end
% k>=3: lookup lógico
for k = 3:length(a_valid)
if achou; break; end
n(w,k-1) = a_valid(w,k-1);
col_atual = a_valid(k);
s2 = uns_sets{col_atual};
if isempty(candidatas) || isempty(s2)
proximas = [];
else
mask = candidatas <= numel(s2);
cand_validas = candidatas(mask);
if isempty(cand_validas); proximas = [];
else; proximas = cand_validas(s2(cand_validas)); end
end
if isempty(proximas)
melhor_erro = col_atual – 1;
melhor_linha = linha_at(38);
n(w,k) = a_valid(w,k);
nP = length(n);
lo = offset + 1; hi = num_linhas; ultlin_abs = offset;
if all(ERO(lo, 1:nP) == n)
while lo <= hi
mid = floor((lo + hi) / 2);
if all(ERO(mid, 1:nP) == n)
ultlin_abs = mid; lo = mid + 1;
else; hi = mid – 1; end
end
end
if ultlin_abs > offset; offset = ultlin_abs;
else; offset = offset + 1; end
n = [];
Relatorio(y,1) = Erros_a(i1,40);
Relatorio(y,2) = candidatas(1);
Relatorio(y,3) = melhor_linha;
Relatorio(y,4) = melhor_erro;
y = y + 1;
achou = true;
break;
end
candidatas = proximas;
melhor_linha = candidatas(1);
end % for k
if ~achou; offset = offset + 1; end
end % while
clear ERO uns_sets;
Relatorio = sortrows(Relatorio, 4, ‘descend’);
Relatorio_final(i1,:) = Relatorio(1,:);
Relatorio(:,:) = 0;
a = a + 1;
end % i1
toc script slow MATLAB Answers — New Questions
Multithreding causing system crashes on linux
Hello,
Im trying to run a rather heavy calculation on our server, and high levels of multithreading causes the system to crash, sadly without crash log. The system does not respond to anything, both over the network and pressing the power button, and requires the power connection to be pulled before it can restart.
The linux version is "Ubunto 24.04.2 LTS", with two AMD EPYC 7763 64-Core Processor CPUs, about 1 TB of ram, a GeForce RTX 3050 8GB graphics card and a Supermicro H12DSi-NT6 mainboard.
When I use parpool and maxNumCompThreads at 16, the system works fine, but rather slow. At 32, the system works fine for a couple of minutes, before crashing, even when the CPU and Ram load never goes above 20%.
The computations include ffts, interpolation and complex to real and vice versa conversions.
Do you have any tips or hints where I can check what is happening, or do you have any information what is going on and what I can do to resolve this problem?
ThanksHello,
Im trying to run a rather heavy calculation on our server, and high levels of multithreading causes the system to crash, sadly without crash log. The system does not respond to anything, both over the network and pressing the power button, and requires the power connection to be pulled before it can restart.
The linux version is "Ubunto 24.04.2 LTS", with two AMD EPYC 7763 64-Core Processor CPUs, about 1 TB of ram, a GeForce RTX 3050 8GB graphics card and a Supermicro H12DSi-NT6 mainboard.
When I use parpool and maxNumCompThreads at 16, the system works fine, but rather slow. At 32, the system works fine for a couple of minutes, before crashing, even when the CPU and Ram load never goes above 20%.
The computations include ffts, interpolation and complex to real and vice versa conversions.
Do you have any tips or hints where I can check what is happening, or do you have any information what is going on and what I can do to resolve this problem?
Thanks Hello,
Im trying to run a rather heavy calculation on our server, and high levels of multithreading causes the system to crash, sadly without crash log. The system does not respond to anything, both over the network and pressing the power button, and requires the power connection to be pulled before it can restart.
The linux version is "Ubunto 24.04.2 LTS", with two AMD EPYC 7763 64-Core Processor CPUs, about 1 TB of ram, a GeForce RTX 3050 8GB graphics card and a Supermicro H12DSi-NT6 mainboard.
When I use parpool and maxNumCompThreads at 16, the system works fine, but rather slow. At 32, the system works fine for a couple of minutes, before crashing, even when the CPU and Ram load never goes above 20%.
The computations include ffts, interpolation and complex to real and vice versa conversions.
Do you have any tips or hints where I can check what is happening, or do you have any information what is going on and what I can do to resolve this problem?
Thanks parfor, multithreading, error, performance MATLAB Answers — New Questions
How to sign an .mlapp app packaged using MATLAB App designer?
Using Share to "Standalone Desktop App" in MATLAB App Designer, Is there a way to sign the installer .exe file that is generated, and also sign the application .exe file that is generated after the installation file is run? Currently, when using App Designer to package the app, it creates a build of the app and then packages it into an installation .exe file in the same workflow.
The issue I’m forseeing is that if I sign the installation .exe file, the application .exe file within will still be un-signed when it is generated after the installer is run. Am I right in thinking this? If so, is there a method of ensuring the application .exe file within is signed?Using Share to "Standalone Desktop App" in MATLAB App Designer, Is there a way to sign the installer .exe file that is generated, and also sign the application .exe file that is generated after the installation file is run? Currently, when using App Designer to package the app, it creates a build of the app and then packages it into an installation .exe file in the same workflow.
The issue I’m forseeing is that if I sign the installation .exe file, the application .exe file within will still be un-signed when it is generated after the installer is run. Am I right in thinking this? If so, is there a method of ensuring the application .exe file within is signed? Using Share to "Standalone Desktop App" in MATLAB App Designer, Is there a way to sign the installer .exe file that is generated, and also sign the application .exe file that is generated after the installation file is run? Currently, when using App Designer to package the app, it creates a build of the app and then packages it into an installation .exe file in the same workflow.
The issue I’m forseeing is that if I sign the installation .exe file, the application .exe file within will still be un-signed when it is generated after the installer is run. Am I right in thinking this? If so, is there a method of ensuring the application .exe file within is signed? app designer, compiler, certificate, signing MATLAB Answers — New Questions
“operation not allowed” when accessing network drive
I get an "operation not allowed" error in Matlab (only in Matlab) on MacOS when trying to access network-mounted RAID drive
Desktop Mac (1) running Macos 26.3.1, has network-mounted a USB-C external RAID drive connected to older desktop Mac (2) running 15.7.4.
I can view, edit, save etc. files on the (remote) RAID system using terminal windows on (1), using Finder, TextEdit, etc.. But attempting to access folders or files from within Matlab R2024b returns the error "operation not allowed".
Both systems (1) & (2) have Matlab given "full disk access" in Settings>Privacy&Security>FullDiskAccess. Both systems have user given read&write access for shared network drive in Finder>Get_Info, in Unix permissions, and in Settings>Sharing>File_Sharing.
Matlab on (2) can read & write files on the (locally-attached) RAID drive. The problem is only when trying to access the RAID drive from within in Matlab on (1).
smbd also has full disk access (as is clear since terminal and other apps can read & write RAID drive over network connection).
Any suggestions would be appreciated.I get an "operation not allowed" error in Matlab (only in Matlab) on MacOS when trying to access network-mounted RAID drive
Desktop Mac (1) running Macos 26.3.1, has network-mounted a USB-C external RAID drive connected to older desktop Mac (2) running 15.7.4.
I can view, edit, save etc. files on the (remote) RAID system using terminal windows on (1), using Finder, TextEdit, etc.. But attempting to access folders or files from within Matlab R2024b returns the error "operation not allowed".
Both systems (1) & (2) have Matlab given "full disk access" in Settings>Privacy&Security>FullDiskAccess. Both systems have user given read&write access for shared network drive in Finder>Get_Info, in Unix permissions, and in Settings>Sharing>File_Sharing.
Matlab on (2) can read & write files on the (locally-attached) RAID drive. The problem is only when trying to access the RAID drive from within in Matlab on (1).
smbd also has full disk access (as is clear since terminal and other apps can read & write RAID drive over network connection).
Any suggestions would be appreciated. I get an "operation not allowed" error in Matlab (only in Matlab) on MacOS when trying to access network-mounted RAID drive
Desktop Mac (1) running Macos 26.3.1, has network-mounted a USB-C external RAID drive connected to older desktop Mac (2) running 15.7.4.
I can view, edit, save etc. files on the (remote) RAID system using terminal windows on (1), using Finder, TextEdit, etc.. But attempting to access folders or files from within Matlab R2024b returns the error "operation not allowed".
Both systems (1) & (2) have Matlab given "full disk access" in Settings>Privacy&Security>FullDiskAccess. Both systems have user given read&write access for shared network drive in Finder>Get_Info, in Unix permissions, and in Settings>Sharing>File_Sharing.
Matlab on (2) can read & write files on the (locally-attached) RAID drive. The problem is only when trying to access the RAID drive from within in Matlab on (1).
smbd also has full disk access (as is clear since terminal and other apps can read & write RAID drive over network connection).
Any suggestions would be appreciated. operation not allowed MATLAB Answers — New Questions
Best way to relabel axis as pi for trig functions.
Hi all, I was looking for ways to relabel my x-axis as pi increments for trig functions and was wondering which one would be most effective.
This is what chatgpt gave, but I wanted to see if there are any better ways to achieve the same result. TIA!!
clc, clearvars
x = linspace(0,2*pi,200);
y = sin(x);
% Plot
figure
hold on
plot(x, y)
% Pi Labeling
xt = 0:pi/2:2*pi;
xticks(xt)
label = compose(‘%g\pi’, xt/pi);
xticklabels(label)Hi all, I was looking for ways to relabel my x-axis as pi increments for trig functions and was wondering which one would be most effective.
This is what chatgpt gave, but I wanted to see if there are any better ways to achieve the same result. TIA!!
clc, clearvars
x = linspace(0,2*pi,200);
y = sin(x);
% Plot
figure
hold on
plot(x, y)
% Pi Labeling
xt = 0:pi/2:2*pi;
xticks(xt)
label = compose(‘%g\pi’, xt/pi);
xticklabels(label) Hi all, I was looking for ways to relabel my x-axis as pi increments for trig functions and was wondering which one would be most effective.
This is what chatgpt gave, but I wanted to see if there are any better ways to achieve the same result. TIA!!
clc, clearvars
x = linspace(0,2*pi,200);
y = sin(x);
% Plot
figure
hold on
plot(x, y)
% Pi Labeling
xt = 0:pi/2:2*pi;
xticks(xt)
label = compose(‘%g\pi’, xt/pi);
xticklabels(label) xtick, label, trigonometry, pi MATLAB Answers — New Questions
Probléme sur mon programme matlab avec la fonction lsqcurvefit
Bonjour la communauté,
enfaite présentatement je travail sur un programme qui permets de recueillir les paramétre du modèle de Cole_cole à partir des mesures que j’ai eu. Donc l’idéé c’est de faire un programme qui va tracer une courbe qui se superpose à la mesure et me donner les paramétre du modèle correspondant. là j’utilise le lsqcurvefit mais le programme me retourne les valeurs d’initialisation et je sais pas ca peut être dû quoi ?
Merci d’avance de votre réponseBonjour la communauté,
enfaite présentatement je travail sur un programme qui permets de recueillir les paramétre du modèle de Cole_cole à partir des mesures que j’ai eu. Donc l’idéé c’est de faire un programme qui va tracer une courbe qui se superpose à la mesure et me donner les paramétre du modèle correspondant. là j’utilise le lsqcurvefit mais le programme me retourne les valeurs d’initialisation et je sais pas ca peut être dû quoi ?
Merci d’avance de votre réponse Bonjour la communauté,
enfaite présentatement je travail sur un programme qui permets de recueillir les paramétre du modèle de Cole_cole à partir des mesures que j’ai eu. Donc l’idéé c’est de faire un programme qui va tracer une courbe qui se superpose à la mesure et me donner les paramétre du modèle correspondant. là j’utilise le lsqcurvefit mais le programme me retourne les valeurs d’initialisation et je sais pas ca peut être dû quoi ?
Merci d’avance de votre réponse mbengue MATLAB Answers — New Questions
“Index exceeds 37” when 35 variables?
So, I’ve been trying to do 3 variable modeling in MATLAB. I have four sets of data (3 variables and one answer), and I’m trying to bet an equation modeling the data. When running the section of the code pasted below, I keep getting "Index exceeds number of array elements. Index must not exceed 37". There are only 35 variables in the code, so I’m not sure why this isn’t working. As far as why I chose this format, I think x and z can be modeled by a quadratic individually, but I figured each variable needed to be the same power, so they’re all 4th power. Any help would be greatly appreciated.
ft = fittype([ …
‘p000 + p100*x + p010*y + p001*z + ‘ …
‘p200*x.^2 + p020*y.^2 + p002*z.^2 + ‘ …
‘p110*x*y + p101*x*z + p011*y*z + ‘ …
‘p300*x.^3 + p030*y.^3 + p003*z.^3 + ‘ …
‘p210*x.^2*y + p201*x.^2*z + p120*x*y.^2 + ‘ …
‘p021*y.^2*z + p102*x*z.^2 + p012*y*z.^2 + ‘ …
‘p111*x*y*z + ‘ …
‘p400*x.^4 + p040*y.^4 + p004*z.^4 + ‘ …
‘p310*x.^3*y + p301*x.^3*z + p130*x*y.^3 + ‘ …
‘p031*y.^3*z + p103*x*z.^3 + p013*y*z.^3 + ‘ …
‘p220*x.^2*y.^2 + p202*x.^2*z.^2 + p022*y.^2*z.^2 + ‘ …
‘p211*x.^2*y*z + p121*x*y.^2*z + p112*x*y*z.^2’], …
‘independent’, {‘x’, ‘y’, ‘z’}, …
‘dependent’, ‘v’);
[fitobject, gof, output] = fit([x, y, z], v, ft);
disp(fitobject)So, I’ve been trying to do 3 variable modeling in MATLAB. I have four sets of data (3 variables and one answer), and I’m trying to bet an equation modeling the data. When running the section of the code pasted below, I keep getting "Index exceeds number of array elements. Index must not exceed 37". There are only 35 variables in the code, so I’m not sure why this isn’t working. As far as why I chose this format, I think x and z can be modeled by a quadratic individually, but I figured each variable needed to be the same power, so they’re all 4th power. Any help would be greatly appreciated.
ft = fittype([ …
‘p000 + p100*x + p010*y + p001*z + ‘ …
‘p200*x.^2 + p020*y.^2 + p002*z.^2 + ‘ …
‘p110*x*y + p101*x*z + p011*y*z + ‘ …
‘p300*x.^3 + p030*y.^3 + p003*z.^3 + ‘ …
‘p210*x.^2*y + p201*x.^2*z + p120*x*y.^2 + ‘ …
‘p021*y.^2*z + p102*x*z.^2 + p012*y*z.^2 + ‘ …
‘p111*x*y*z + ‘ …
‘p400*x.^4 + p040*y.^4 + p004*z.^4 + ‘ …
‘p310*x.^3*y + p301*x.^3*z + p130*x*y.^3 + ‘ …
‘p031*y.^3*z + p103*x*z.^3 + p013*y*z.^3 + ‘ …
‘p220*x.^2*y.^2 + p202*x.^2*z.^2 + p022*y.^2*z.^2 + ‘ …
‘p211*x.^2*y*z + p121*x*y.^2*z + p112*x*y*z.^2’], …
‘independent’, {‘x’, ‘y’, ‘z’}, …
‘dependent’, ‘v’);
[fitobject, gof, output] = fit([x, y, z], v, ft);
disp(fitobject) So, I’ve been trying to do 3 variable modeling in MATLAB. I have four sets of data (3 variables and one answer), and I’m trying to bet an equation modeling the data. When running the section of the code pasted below, I keep getting "Index exceeds number of array elements. Index must not exceed 37". There are only 35 variables in the code, so I’m not sure why this isn’t working. As far as why I chose this format, I think x and z can be modeled by a quadratic individually, but I figured each variable needed to be the same power, so they’re all 4th power. Any help would be greatly appreciated.
ft = fittype([ …
‘p000 + p100*x + p010*y + p001*z + ‘ …
‘p200*x.^2 + p020*y.^2 + p002*z.^2 + ‘ …
‘p110*x*y + p101*x*z + p011*y*z + ‘ …
‘p300*x.^3 + p030*y.^3 + p003*z.^3 + ‘ …
‘p210*x.^2*y + p201*x.^2*z + p120*x*y.^2 + ‘ …
‘p021*y.^2*z + p102*x*z.^2 + p012*y*z.^2 + ‘ …
‘p111*x*y*z + ‘ …
‘p400*x.^4 + p040*y.^4 + p004*z.^4 + ‘ …
‘p310*x.^3*y + p301*x.^3*z + p130*x*y.^3 + ‘ …
‘p031*y.^3*z + p103*x*z.^3 + p013*y*z.^3 + ‘ …
‘p220*x.^2*y.^2 + p202*x.^2*z.^2 + p022*y.^2*z.^2 + ‘ …
‘p211*x.^2*y*z + p121*x*y.^2*z + p112*x*y*z.^2’], …
‘independent’, {‘x’, ‘y’, ‘z’}, …
‘dependent’, ‘v’);
[fitobject, gof, output] = fit([x, y, z], v, ft);
disp(fitobject) error, curve fitting MATLAB Answers — New Questions
How do I determine the linear part of a force-displacement curve?
I have a force-displacement graph (the attached file) and I want to find out exactly at what point the linear portion of the graph ends. Please see the picture for more clarification.
I’ve already smoothed out the curve, so it is noiseless.
I did a quick search but couldn’t find anything useful.
Any help would be highly appreciated.I have a force-displacement graph (the attached file) and I want to find out exactly at what point the linear portion of the graph ends. Please see the picture for more clarification.
I’ve already smoothed out the curve, so it is noiseless.
I did a quick search but couldn’t find anything useful.
Any help would be highly appreciated. I have a force-displacement graph (the attached file) and I want to find out exactly at what point the linear portion of the graph ends. Please see the picture for more clarification.
I’ve already smoothed out the curve, so it is noiseless.
I did a quick search but couldn’t find anything useful.
Any help would be highly appreciated. linear part, nonlinear part MATLAB Answers — New Questions









