Author: PuTI
System requirements for simultaneous Polyspace BugFinder Analyzes on one computer?
Hello. I need to start an indefinite number of BugFinder analyses on a computer at indefinite times as headless. I need 25 minutes to analyze one project, but when I run two different BugFinder analyses on the same project at the same time, the time exceeds 50 minutes and the CPU consumption is 100%.
My question: Is it possible to run more than one analysis without increasing the time and without the computer locking up? Will upgrading CPU cores, RAM or CPU GHZ etc. solve this or will the time increase in any case? If upgrading the hardware will solve the problem, how much should I upgrade?Hello. I need to start an indefinite number of BugFinder analyses on a computer at indefinite times as headless. I need 25 minutes to analyze one project, but when I run two different BugFinder analyses on the same project at the same time, the time exceeds 50 minutes and the CPU consumption is 100%.
My question: Is it possible to run more than one analysis without increasing the time and without the computer locking up? Will upgrading CPU cores, RAM or CPU GHZ etc. solve this or will the time increase in any case? If upgrading the hardware will solve the problem, how much should I upgrade? Hello. I need to start an indefinite number of BugFinder analyses on a computer at indefinite times as headless. I need 25 minutes to analyze one project, but when I run two different BugFinder analyses on the same project at the same time, the time exceeds 50 minutes and the CPU consumption is 100%.
My question: Is it possible to run more than one analysis without increasing the time and without the computer locking up? Will upgrading CPU cores, RAM or CPU GHZ etc. solve this or will the time increase in any case? If upgrading the hardware will solve the problem, how much should I upgrade? bugfinder, polyspace MATLAB Answers — New Questions
Optimization of water distribution network, objective is to get optimal cost
I want to ask how I should use any optimization algorithm with EPANET to obtained optimal diameter and optimal cost?
After using the code attached, I am unable to get the optimal cost; it is always coming ‘inf’ even if I am using a minimum pressure requirement of 30 m for nodes, minimum velocity 0, and maximum velocity ‘inf’ for links. I am using the Hanoi network, which has 34 links, for hydraulic simulation, I am using EPANET I am also attaching the Matlab code that I am using. It would be very nice of you if anyone could help me with this.
% GENETIC ALGORITHM (GA) SETUP
clear; close(‘all’); clc;
start_toolkit;
%d = epanet(‘C:UsersAdminDesktopPipeNetworkPN_codeHanoi.inp’);
% Define GA options for optimization
options = optimoptions(‘ga’, ‘Display’, ‘iter’, ‘PopulationSize’, 16, …
‘MaxGenerations’, 6, ‘UseParallel’, false);
% Define number of pipes in the network
nvars = 34; % Number of pipes
diameterOptions = [304.8, 406.4, 508, 609.6, 762, 1016]; % Available diameters in mm
costPerDiameter = [45.73, 70.4, 98.38, 129.333, 180.8, 278.3]; % Cost per unit length for each diameter
% Define lower and upper bounds for pipe diameters
lb = repmat(min(diameterOptions), 1, nvars); % Minimum diameter constraint
ub = repmat(max(diameterOptions), 1, nvars); % Maximum diameter constraint
% Run Genetic Algorithm (GA) for optimal pipe diameter selection
[optimalDiameters, optimalCost] = ga(@pipeNetworkObjective, nvars, [], [], [], [], lb, ub, [], options);
% Display optimization results
fprintf(‘Optimal Pipe Diameters:n’);
disp(optimalDiameters);
fprintf(‘Optimal Cost:n’);
disp(optimalCost);
function cost = pipeNetworkObjective(diameters)
% Load EPANET-MATLAB Toolkit
start_toolkit;
d = epanet(‘Optimal_Configuration_eta_2.00.inp’);
% Set pipe diameters based on GA input
for i = 1:length(diameters)
d.setLinkDiameter(i, diameters(i));
end
% Run hydraulic simulation
d.solveCompleteHydraulics;
% Check constraints
pressures = d.getNodePressure;
velocities = d.getLinkVelocity;
if any(pressures < 0) || any(velocities < 0) || any(velocities > inf)
cost = inf; % Penalize infeasible solutions
else
% Calculate cost based on diameters
cost = calculateCost(diameters);
end
% Close EPANET
d.unload;
end
function totalCost = calculateCost(diameters)
% Define cost per diameter (example values)
diameterOptions = [304.8, 406.4, 508, 609.6, 762, 1016]; % Available diameters in mm
costPerDiameter = [45.73, 70.4, 98.38, 129.333, 180.8, 278.3]; % Cost per unit length for each diameter
% Calculate total cost
totalCost = 0;
for i = 1:length(diameters)
idx = find(diameterOptions == diameters(i));
totalCost = totalCost + costPerDiameter(idx);
end
endI want to ask how I should use any optimization algorithm with EPANET to obtained optimal diameter and optimal cost?
After using the code attached, I am unable to get the optimal cost; it is always coming ‘inf’ even if I am using a minimum pressure requirement of 30 m for nodes, minimum velocity 0, and maximum velocity ‘inf’ for links. I am using the Hanoi network, which has 34 links, for hydraulic simulation, I am using EPANET I am also attaching the Matlab code that I am using. It would be very nice of you if anyone could help me with this.
% GENETIC ALGORITHM (GA) SETUP
clear; close(‘all’); clc;
start_toolkit;
%d = epanet(‘C:UsersAdminDesktopPipeNetworkPN_codeHanoi.inp’);
% Define GA options for optimization
options = optimoptions(‘ga’, ‘Display’, ‘iter’, ‘PopulationSize’, 16, …
‘MaxGenerations’, 6, ‘UseParallel’, false);
% Define number of pipes in the network
nvars = 34; % Number of pipes
diameterOptions = [304.8, 406.4, 508, 609.6, 762, 1016]; % Available diameters in mm
costPerDiameter = [45.73, 70.4, 98.38, 129.333, 180.8, 278.3]; % Cost per unit length for each diameter
% Define lower and upper bounds for pipe diameters
lb = repmat(min(diameterOptions), 1, nvars); % Minimum diameter constraint
ub = repmat(max(diameterOptions), 1, nvars); % Maximum diameter constraint
% Run Genetic Algorithm (GA) for optimal pipe diameter selection
[optimalDiameters, optimalCost] = ga(@pipeNetworkObjective, nvars, [], [], [], [], lb, ub, [], options);
% Display optimization results
fprintf(‘Optimal Pipe Diameters:n’);
disp(optimalDiameters);
fprintf(‘Optimal Cost:n’);
disp(optimalCost);
function cost = pipeNetworkObjective(diameters)
% Load EPANET-MATLAB Toolkit
start_toolkit;
d = epanet(‘Optimal_Configuration_eta_2.00.inp’);
% Set pipe diameters based on GA input
for i = 1:length(diameters)
d.setLinkDiameter(i, diameters(i));
end
% Run hydraulic simulation
d.solveCompleteHydraulics;
% Check constraints
pressures = d.getNodePressure;
velocities = d.getLinkVelocity;
if any(pressures < 0) || any(velocities < 0) || any(velocities > inf)
cost = inf; % Penalize infeasible solutions
else
% Calculate cost based on diameters
cost = calculateCost(diameters);
end
% Close EPANET
d.unload;
end
function totalCost = calculateCost(diameters)
% Define cost per diameter (example values)
diameterOptions = [304.8, 406.4, 508, 609.6, 762, 1016]; % Available diameters in mm
costPerDiameter = [45.73, 70.4, 98.38, 129.333, 180.8, 278.3]; % Cost per unit length for each diameter
% Calculate total cost
totalCost = 0;
for i = 1:length(diameters)
idx = find(diameterOptions == diameters(i));
totalCost = totalCost + costPerDiameter(idx);
end
end I want to ask how I should use any optimization algorithm with EPANET to obtained optimal diameter and optimal cost?
After using the code attached, I am unable to get the optimal cost; it is always coming ‘inf’ even if I am using a minimum pressure requirement of 30 m for nodes, minimum velocity 0, and maximum velocity ‘inf’ for links. I am using the Hanoi network, which has 34 links, for hydraulic simulation, I am using EPANET I am also attaching the Matlab code that I am using. It would be very nice of you if anyone could help me with this.
% GENETIC ALGORITHM (GA) SETUP
clear; close(‘all’); clc;
start_toolkit;
%d = epanet(‘C:UsersAdminDesktopPipeNetworkPN_codeHanoi.inp’);
% Define GA options for optimization
options = optimoptions(‘ga’, ‘Display’, ‘iter’, ‘PopulationSize’, 16, …
‘MaxGenerations’, 6, ‘UseParallel’, false);
% Define number of pipes in the network
nvars = 34; % Number of pipes
diameterOptions = [304.8, 406.4, 508, 609.6, 762, 1016]; % Available diameters in mm
costPerDiameter = [45.73, 70.4, 98.38, 129.333, 180.8, 278.3]; % Cost per unit length for each diameter
% Define lower and upper bounds for pipe diameters
lb = repmat(min(diameterOptions), 1, nvars); % Minimum diameter constraint
ub = repmat(max(diameterOptions), 1, nvars); % Maximum diameter constraint
% Run Genetic Algorithm (GA) for optimal pipe diameter selection
[optimalDiameters, optimalCost] = ga(@pipeNetworkObjective, nvars, [], [], [], [], lb, ub, [], options);
% Display optimization results
fprintf(‘Optimal Pipe Diameters:n’);
disp(optimalDiameters);
fprintf(‘Optimal Cost:n’);
disp(optimalCost);
function cost = pipeNetworkObjective(diameters)
% Load EPANET-MATLAB Toolkit
start_toolkit;
d = epanet(‘Optimal_Configuration_eta_2.00.inp’);
% Set pipe diameters based on GA input
for i = 1:length(diameters)
d.setLinkDiameter(i, diameters(i));
end
% Run hydraulic simulation
d.solveCompleteHydraulics;
% Check constraints
pressures = d.getNodePressure;
velocities = d.getLinkVelocity;
if any(pressures < 0) || any(velocities < 0) || any(velocities > inf)
cost = inf; % Penalize infeasible solutions
else
% Calculate cost based on diameters
cost = calculateCost(diameters);
end
% Close EPANET
d.unload;
end
function totalCost = calculateCost(diameters)
% Define cost per diameter (example values)
diameterOptions = [304.8, 406.4, 508, 609.6, 762, 1016]; % Available diameters in mm
costPerDiameter = [45.73, 70.4, 98.38, 129.333, 180.8, 278.3]; % Cost per unit length for each diameter
% Calculate total cost
totalCost = 0;
for i = 1:length(diameters)
idx = find(diameterOptions == diameters(i));
totalCost = totalCost + costPerDiameter(idx);
end
end optimization of epanet network using ga toolkit MATLAB Answers — New Questions
how to Align values
%price of each
TV_price = 20000.00;
LAPTOP_price = 40000.00;
SPEAKER_price = 6000.00;
MOUSE_price = 1000.00;
KEYBOARD_price = 3000.00;
%get input from user
TV = input(‘How many TVs were sold? ‘);
LAPTOP = input(‘How many Laptops were sold? ‘);
SPEAKER = input(‘How many Speakers were sold? ‘);
MOUSE = input(‘How many Computer Mouse were sold? ‘);
KEYBOARD = input(‘How many Keyboards were sold? ‘);
fprintf("n—————————————————–n");
%print bill
%Display
fprintf("nQTYtDESCRIPTIONttUNIT PRICEtTOTAL PRICEn");
fprintf("n—t———–tt———t———n");
fprintf("%dtTVtt%.2ft%.2fn",TV,TV_price,TV*TV_price);
fprintf("%dtLAPTOPtt%.2ft%.2fn",LAPTOP,LAPTOP_price,LAPTOP*LAPTOP_price);
fprintf("%dtSPEAKERtt%.2ftt%.2fn",SPEAKER,SPEAKER_price,SPEAKER*SPEAKER_price);
fprintf("%dtMOUSEtt%.2ftt%.2fn",MOUSE,MOUSE_price,MOUSE*MOUSE_price);
fprintf("%dtKEYBOARDt%.2ftt%.2fn",KEYBOARD,KEYBOARD_price,KEYBOARD*KEYBOARD_price);
total = (TV*TV_price)+(LAPTOP*LAPTOP_price)+(SPEAKER*SPEAKER_price)+(MOUSE*MOUSE_price)+(KEYBOARD*KEYBOARD_price);
tax = (total/100)*8.25;
fprintf("ttttt———-n");
fprintf("tttSUBTOTALt%.2fn",total);
fprintf("tttTAXEStt%.2fn",tax)
fprintf("tttTOTALtt%.2fn",total+tax);%price of each
TV_price = 20000.00;
LAPTOP_price = 40000.00;
SPEAKER_price = 6000.00;
MOUSE_price = 1000.00;
KEYBOARD_price = 3000.00;
%get input from user
TV = input(‘How many TVs were sold? ‘);
LAPTOP = input(‘How many Laptops were sold? ‘);
SPEAKER = input(‘How many Speakers were sold? ‘);
MOUSE = input(‘How many Computer Mouse were sold? ‘);
KEYBOARD = input(‘How many Keyboards were sold? ‘);
fprintf("n—————————————————–n");
%print bill
%Display
fprintf("nQTYtDESCRIPTIONttUNIT PRICEtTOTAL PRICEn");
fprintf("n—t———–tt———t———n");
fprintf("%dtTVtt%.2ft%.2fn",TV,TV_price,TV*TV_price);
fprintf("%dtLAPTOPtt%.2ft%.2fn",LAPTOP,LAPTOP_price,LAPTOP*LAPTOP_price);
fprintf("%dtSPEAKERtt%.2ftt%.2fn",SPEAKER,SPEAKER_price,SPEAKER*SPEAKER_price);
fprintf("%dtMOUSEtt%.2ftt%.2fn",MOUSE,MOUSE_price,MOUSE*MOUSE_price);
fprintf("%dtKEYBOARDt%.2ftt%.2fn",KEYBOARD,KEYBOARD_price,KEYBOARD*KEYBOARD_price);
total = (TV*TV_price)+(LAPTOP*LAPTOP_price)+(SPEAKER*SPEAKER_price)+(MOUSE*MOUSE_price)+(KEYBOARD*KEYBOARD_price);
tax = (total/100)*8.25;
fprintf("ttttt———-n");
fprintf("tttSUBTOTALt%.2fn",total);
fprintf("tttTAXEStt%.2fn",tax)
fprintf("tttTOTALtt%.2fn",total+tax); %price of each
TV_price = 20000.00;
LAPTOP_price = 40000.00;
SPEAKER_price = 6000.00;
MOUSE_price = 1000.00;
KEYBOARD_price = 3000.00;
%get input from user
TV = input(‘How many TVs were sold? ‘);
LAPTOP = input(‘How many Laptops were sold? ‘);
SPEAKER = input(‘How many Speakers were sold? ‘);
MOUSE = input(‘How many Computer Mouse were sold? ‘);
KEYBOARD = input(‘How many Keyboards were sold? ‘);
fprintf("n—————————————————–n");
%print bill
%Display
fprintf("nQTYtDESCRIPTIONttUNIT PRICEtTOTAL PRICEn");
fprintf("n—t———–tt———t———n");
fprintf("%dtTVtt%.2ft%.2fn",TV,TV_price,TV*TV_price);
fprintf("%dtLAPTOPtt%.2ft%.2fn",LAPTOP,LAPTOP_price,LAPTOP*LAPTOP_price);
fprintf("%dtSPEAKERtt%.2ftt%.2fn",SPEAKER,SPEAKER_price,SPEAKER*SPEAKER_price);
fprintf("%dtMOUSEtt%.2ftt%.2fn",MOUSE,MOUSE_price,MOUSE*MOUSE_price);
fprintf("%dtKEYBOARDt%.2ftt%.2fn",KEYBOARD,KEYBOARD_price,KEYBOARD*KEYBOARD_price);
total = (TV*TV_price)+(LAPTOP*LAPTOP_price)+(SPEAKER*SPEAKER_price)+(MOUSE*MOUSE_price)+(KEYBOARD*KEYBOARD_price);
tax = (total/100)*8.25;
fprintf("ttttt———-n");
fprintf("tttSUBTOTALt%.2fn",total);
fprintf("tttTAXEStt%.2fn",tax)
fprintf("tttTOTALtt%.2fn",total+tax); align values MATLAB Answers — New Questions
Simulink model not running in real time
If using ‘Connected IO’ it runs in real time but ‘Run on board’ it doesn’t. When in ‘Run on board’ every 1 second in real time is 0.001 seconds in Simulink. When using ‘Connected IO’ no data is displayed from the ultrasonic sensor.If using ‘Connected IO’ it runs in real time but ‘Run on board’ it doesn’t. When in ‘Run on board’ every 1 second in real time is 0.001 seconds in Simulink. When using ‘Connected IO’ no data is displayed from the ultrasonic sensor. If using ‘Connected IO’ it runs in real time but ‘Run on board’ it doesn’t. When in ‘Run on board’ every 1 second in real time is 0.001 seconds in Simulink. When using ‘Connected IO’ no data is displayed from the ultrasonic sensor. simulink, arduino MATLAB Answers — New Questions
Why matlab is outputting test values even though everything is suppressed?
I’m writing a function to find the roots of an inputted function and I’ve suppressed everything and I’m trying to make it run without any outputs, but I keep getting outputs that say test equals a number and I can’t figure out why. If everything is suppressed why is this still being outputted and how do I fix it?I’m writing a function to find the roots of an inputted function and I’ve suppressed everything and I’m trying to make it run without any outputs, but I keep getting outputs that say test equals a number and I can’t figure out why. If everything is suppressed why is this still being outputted and how do I fix it? I’m writing a function to find the roots of an inputted function and I’ve suppressed everything and I’m trying to make it run without any outputs, but I keep getting outputs that say test equals a number and I can’t figure out why. If everything is suppressed why is this still being outputted and how do I fix it? matlab functions MATLAB Answers — New Questions
Command lines appear when I run an app.
Hello everyone,
I am making an app on "Matlab app designer" and in a near future, when I have the app done, I would like to have it like an executable, I mean, like a program.
The point is that whenever I open Matlab app designer and run my app, in the command window of matlab appears all the names and dimensions of the widgets that are on my app (boxes, menus, text, windows…etc) as you can see in the photo below.
Is this supposed to happen, or is it supposed to be the command window clear without any command line? If in a near future I would like to export my app like an executable archive, do I have to get rid off this phenomenon?
Thank you very muchHello everyone,
I am making an app on "Matlab app designer" and in a near future, when I have the app done, I would like to have it like an executable, I mean, like a program.
The point is that whenever I open Matlab app designer and run my app, in the command window of matlab appears all the names and dimensions of the widgets that are on my app (boxes, menus, text, windows…etc) as you can see in the photo below.
Is this supposed to happen, or is it supposed to be the command window clear without any command line? If in a near future I would like to export my app like an executable archive, do I have to get rid off this phenomenon?
Thank you very much Hello everyone,
I am making an app on "Matlab app designer" and in a near future, when I have the app done, I would like to have it like an executable, I mean, like a program.
The point is that whenever I open Matlab app designer and run my app, in the command window of matlab appears all the names and dimensions of the widgets that are on my app (boxes, menus, text, windows…etc) as you can see in the photo below.
Is this supposed to happen, or is it supposed to be the command window clear without any command line? If in a near future I would like to export my app like an executable archive, do I have to get rid off this phenomenon?
Thank you very much app, matlab app designer, command lines, command, lines, matlab, run MATLAB Answers — New Questions
how to adjust the time axis in Simulink scope
Hi all,
I have adjust the maxium time axis is 20s but the simulation stop until 10s as shown in the attached picture. Please help, thank youHi all,
I have adjust the maxium time axis is 20s but the simulation stop until 10s as shown in the attached picture. Please help, thank you Hi all,
I have adjust the maxium time axis is 20s but the simulation stop until 10s as shown in the attached picture. Please help, thank you time axis of scope simulink MATLAB Answers — New Questions
Audioread Bug with Opus (maximum value returned exceeding 1)
Hello,
I think there is a bug with the audioread function and opus files. Somehow, I am getting maximum values read > 1. The files are perfectly fine and from a well mastered cd and opus files were made with ffmpeg from it. I have tried running this code in matlab 2023b and 2025a pre release, issue is persisting. Please help.
Output:
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorinput.wav
Max Value: 0.98535 0.98593
Filename: ‘C:UsersAdminDesktopDatasetsCompressorinput.wav’
CompressionMethod: ‘Uncompressed’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166800900
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
BitsPerSample: 16
————————————————–
————————————————–
"File: " "C:UsersAdminDesktopDatasetsCompressorMP3_EncodesC…"
Max Value: 1 1
Filename: ‘C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3’
CompressionMethod: ‘MP3’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166803837
Duration: 3.7824e+03
Title: []
Comment: []
Artist: []
BitRate: 128
————————————————–
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus
Max Value: 1.3834 1.4113
Filename: ‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
CompressionMethod: ‘Opus’
NumChannels: 2
SampleRate: 48000
TotalSamples: 181552000
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
————————————————–
Code to reproduce bug:
% Define the list of input files (add more file paths as needed)
inputFiles = {
‘C:UsersAdminDesktopDatasetsCompressorinput.wav’, %original wav file
"C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3",
‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
};
% Loop through each input file
for i = 1:length(inputFiles)
% Get the current input file path
inputFile = inputFiles{i};
% Read the audio file
[audioIn, inputFs] = audioread(inputFile);
% Find the maximum absolute value in the audio data
maxValue = max(abs(audioIn));
% Display the result for each file in a more readable format using disp
disp(‘————————————————–‘);
disp([‘File: ‘, inputFile]);
disp([‘Max Value: ‘, num2str(maxValue)]);
info = audioinfo(inputFile);
disp(info);
disp(‘————————————————–‘);
end
EDIT:
The plot thickens, as a factor of sqrt(2) appears before the weights in the opus with all files I tested vs the mp3 and wav weights.Hello,
I think there is a bug with the audioread function and opus files. Somehow, I am getting maximum values read > 1. The files are perfectly fine and from a well mastered cd and opus files were made with ffmpeg from it. I have tried running this code in matlab 2023b and 2025a pre release, issue is persisting. Please help.
Output:
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorinput.wav
Max Value: 0.98535 0.98593
Filename: ‘C:UsersAdminDesktopDatasetsCompressorinput.wav’
CompressionMethod: ‘Uncompressed’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166800900
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
BitsPerSample: 16
————————————————–
————————————————–
"File: " "C:UsersAdminDesktopDatasetsCompressorMP3_EncodesC…"
Max Value: 1 1
Filename: ‘C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3’
CompressionMethod: ‘MP3’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166803837
Duration: 3.7824e+03
Title: []
Comment: []
Artist: []
BitRate: 128
————————————————–
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus
Max Value: 1.3834 1.4113
Filename: ‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
CompressionMethod: ‘Opus’
NumChannels: 2
SampleRate: 48000
TotalSamples: 181552000
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
————————————————–
Code to reproduce bug:
% Define the list of input files (add more file paths as needed)
inputFiles = {
‘C:UsersAdminDesktopDatasetsCompressorinput.wav’, %original wav file
"C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3",
‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
};
% Loop through each input file
for i = 1:length(inputFiles)
% Get the current input file path
inputFile = inputFiles{i};
% Read the audio file
[audioIn, inputFs] = audioread(inputFile);
% Find the maximum absolute value in the audio data
maxValue = max(abs(audioIn));
% Display the result for each file in a more readable format using disp
disp(‘————————————————–‘);
disp([‘File: ‘, inputFile]);
disp([‘Max Value: ‘, num2str(maxValue)]);
info = audioinfo(inputFile);
disp(info);
disp(‘————————————————–‘);
end
EDIT:
The plot thickens, as a factor of sqrt(2) appears before the weights in the opus with all files I tested vs the mp3 and wav weights. Hello,
I think there is a bug with the audioread function and opus files. Somehow, I am getting maximum values read > 1. The files are perfectly fine and from a well mastered cd and opus files were made with ffmpeg from it. I have tried running this code in matlab 2023b and 2025a pre release, issue is persisting. Please help.
Output:
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorinput.wav
Max Value: 0.98535 0.98593
Filename: ‘C:UsersAdminDesktopDatasetsCompressorinput.wav’
CompressionMethod: ‘Uncompressed’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166800900
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
BitsPerSample: 16
————————————————–
————————————————–
"File: " "C:UsersAdminDesktopDatasetsCompressorMP3_EncodesC…"
Max Value: 1 1
Filename: ‘C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3’
CompressionMethod: ‘MP3’
NumChannels: 2
SampleRate: 44100
TotalSamples: 166803837
Duration: 3.7824e+03
Title: []
Comment: []
Artist: []
BitRate: 128
————————————————–
————————————————–
File: C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus
Max Value: 1.3834 1.4113
Filename: ‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
CompressionMethod: ‘Opus’
NumChannels: 2
SampleRate: 48000
TotalSamples: 181552000
Duration: 3.7823e+03
Title: []
Comment: []
Artist: []
————————————————–
Code to reproduce bug:
% Define the list of input files (add more file paths as needed)
inputFiles = {
‘C:UsersAdminDesktopDatasetsCompressorinput.wav’, %original wav file
"C:UsersAdminDesktopDatasetsCompressorMP3_EncodesCBRCBR_128_MP3.mp3",
‘C:UsersAdminDesktopDatasetsCompressorOpus_PresetsCBRCBR_128_Opus.opus’
};
% Loop through each input file
for i = 1:length(inputFiles)
% Get the current input file path
inputFile = inputFiles{i};
% Read the audio file
[audioIn, inputFs] = audioread(inputFile);
% Find the maximum absolute value in the audio data
maxValue = max(abs(audioIn));
% Display the result for each file in a more readable format using disp
disp(‘————————————————–‘);
disp([‘File: ‘, inputFile]);
disp([‘Max Value: ‘, num2str(maxValue)]);
info = audioinfo(inputFile);
disp(info);
disp(‘————————————————–‘);
end
EDIT:
The plot thickens, as a factor of sqrt(2) appears before the weights in the opus with all files I tested vs the mp3 and wav weights. audio, bug, audioread MATLAB Answers — New Questions
How to create inline S function?
During code generation, RTW build fails since the s function is not in line. How to manage tunable parameter in S function?During code generation, RTW build fails since the s function is not in line. How to manage tunable parameter in S function? During code generation, RTW build fails since the s function is not in line. How to manage tunable parameter in S function? formulastudent MATLAB Answers — New Questions
Assign fitlme output to a variable
Is there a way to output specific fitlme parameters? Specifically, how can I assign the t-statistic value to a specified variable? I see how to output the entire fitlme model, but not how to extract a specific value in a function.Is there a way to output specific fitlme parameters? Specifically, how can I assign the t-statistic value to a specified variable? I see how to output the entire fitlme model, but not how to extract a specific value in a function. Is there a way to output specific fitlme parameters? Specifically, how can I assign the t-statistic value to a specified variable? I see how to output the entire fitlme model, but not how to extract a specific value in a function. fitlme MATLAB Answers — New Questions
Assign fitlme output to a variable
Is there a way to output specific fitlme parameters? Specifically, how can I assign the t-statistic value to a specified variable? I see how to output the entire fitlme model, but not how to extract a specific value in a function.Is there a way to output specific fitlme parameters? Specifically, how can I assign the t-statistic value to a specified variable? I see how to output the entire fitlme model, but not how to extract a specific value in a function. Is there a way to output specific fitlme parameters? Specifically, how can I assign the t-statistic value to a specified variable? I see how to output the entire fitlme model, but not how to extract a specific value in a function. fitlme MATLAB Answers — New Questions
How can self-organized Simulink model/block information be written to a file during Simulink code generation?
I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed.I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed. I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed. simulink, code generation, embedded coder, system target file, tlc MATLAB Answers — New Questions
How can self-organized Simulink model/block information be written to a file during Simulink code generation?
I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed.I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed. I maintain some data structures in the callback functions of my customized Simulink blocks and would like to write them to a source file or a formatted configuration file when generating C code. Simulink can load custom TLC (Target Language Compiler) files through a custom System Target File and read model configuration information. TLC can read model configurations or RTW files to obtain model-related information and write the relevant data into C source files or header files. However, TLC doesn’t handle structured data well.
I have tried the following:
1. Writing data to the MATLAB workspace via the model block callback functions and then reading from TLC, but TLC cannot access the MATLAB workspace (e.g., via TLC `eval` function or %matlab or others) when generating code.
2. Writing data to a custom model configuration page (by modifying the System Target File) and then reading configuration items during TLC code generation, but this is not very friendly for complex data structures.
Is there any elegant way to pass complex private data structures into the source code? This is somewhat similar to a serialization requirement, where the callback function m in the model serializes the data, and then in C language, the data is deserialized and parsed. simulink, code generation, embedded coder, system target file, tlc MATLAB Answers — New Questions
Spectrometer signal processing.
Hi guys,
I got my spectrometer data in this format save as a notepad file:
I would like to covnert time on the graph strat from 0 seconds and dont know how to covvert that.
Units_11:211
1729167932375 13:25:32.375 405650.13
1729167932475 13:25:32.475 400621.04
1729167932575 13:25:32.575 398764.17
1729167932675 13:25:32.675 400905.63
1729167932775 13:25:32.775 400606.19
1729167932875 13:25:32.875 400141.29
Can someone help me with that? Thank youHi guys,
I got my spectrometer data in this format save as a notepad file:
I would like to covnert time on the graph strat from 0 seconds and dont know how to covvert that.
Units_11:211
1729167932375 13:25:32.375 405650.13
1729167932475 13:25:32.475 400621.04
1729167932575 13:25:32.575 398764.17
1729167932675 13:25:32.675 400905.63
1729167932775 13:25:32.775 400606.19
1729167932875 13:25:32.875 400141.29
Can someone help me with that? Thank you Hi guys,
I got my spectrometer data in this format save as a notepad file:
I would like to covnert time on the graph strat from 0 seconds and dont know how to covvert that.
Units_11:211
1729167932375 13:25:32.375 405650.13
1729167932475 13:25:32.475 400621.04
1729167932575 13:25:32.575 398764.17
1729167932675 13:25:32.675 400905.63
1729167932775 13:25:32.775 400606.19
1729167932875 13:25:32.875 400141.29
Can someone help me with that? Thank you spectrometer signal processing MATLAB Answers — New Questions
Error in extracting CTF file / Could not close zip entry that was open for read
Hello, I’m using software that runs on Matlab runtime R2016b (9.1) x64 on windows 8.1
When I run the exe from a command line it exits with the following:
C:>Error in extracting CTF file to ‘L:TempAlexAlexmcrCache9.1FlopFa0’. Details: ‘Could not close zip entry that was open for read’
Could not access the MATLAB Runtime component cache. Details: Some error has occurred in the file: b:matlabstandalonemclmcrcoremclctffileextractor.cpp, at line: 64.
The error message is:
Error in extracting CTF file to ‘L:TempAlexAlexmcrCache9.1FlopFa0’. Details: ‘Could not close zip entry that was open for read’
L:Temp is the environment var temp.
So far I’ve tried:
* reinstalling (including deleting the runtime dir after uninstall)
* installing to different drives
* moving the temp folder to other drives
But the error is the same. If anyone could offer any insight/suggestiosn I’d appreciate it.
ThanksHello, I’m using software that runs on Matlab runtime R2016b (9.1) x64 on windows 8.1
When I run the exe from a command line it exits with the following:
C:>Error in extracting CTF file to ‘L:TempAlexAlexmcrCache9.1FlopFa0’. Details: ‘Could not close zip entry that was open for read’
Could not access the MATLAB Runtime component cache. Details: Some error has occurred in the file: b:matlabstandalonemclmcrcoremclctffileextractor.cpp, at line: 64.
The error message is:
Error in extracting CTF file to ‘L:TempAlexAlexmcrCache9.1FlopFa0’. Details: ‘Could not close zip entry that was open for read’
L:Temp is the environment var temp.
So far I’ve tried:
* reinstalling (including deleting the runtime dir after uninstall)
* installing to different drives
* moving the temp folder to other drives
But the error is the same. If anyone could offer any insight/suggestiosn I’d appreciate it.
Thanks Hello, I’m using software that runs on Matlab runtime R2016b (9.1) x64 on windows 8.1
When I run the exe from a command line it exits with the following:
C:>Error in extracting CTF file to ‘L:TempAlexAlexmcrCache9.1FlopFa0’. Details: ‘Could not close zip entry that was open for read’
Could not access the MATLAB Runtime component cache. Details: Some error has occurred in the file: b:matlabstandalonemclmcrcoremclctffileextractor.cpp, at line: 64.
The error message is:
Error in extracting CTF file to ‘L:TempAlexAlexmcrCache9.1FlopFa0’. Details: ‘Could not close zip entry that was open for read’
L:Temp is the environment var temp.
So far I’ve tried:
* reinstalling (including deleting the runtime dir after uninstall)
* installing to different drives
* moving the temp folder to other drives
But the error is the same. If anyone could offer any insight/suggestiosn I’d appreciate it.
Thanks startup MATLAB Answers — New Questions
plot an image with axes that match the source surface plot
I am having a problem getting a match between a surface plot and an image of the plot. This is possibly to do with NaNs along border and the problem addressed in https://uk.mathworks.com/matlabcentral/answers/484482-surf-and-nan-plotting-bug. However, I have tried a range of adjustments to the axis without success. Any pointers gratefully appreciated. Some sample code and a grid file:
%load the grid
load(‘test_grid’,’-mat’); %load the grid struct
Z = grid.z’;
hf = figure(‘Tag’,’PlotFig’);
ax = axes(hf);
C = pcolor(ax,grid.x,grid.y,Z);
shading interp
axis equal tight
delX = abs(grid.x(2)-grid.x(1));
delY = abs(grid.y(2)-grid.y(1));
xLim = xlim;
yLim = ylim;
%adjusting the x and y limits seems to have no effect on the image plot
yLim(2) = yLim(2)-delY*10;
%overlay a derived image on the original plot
hold(ax,’on’)
h_im = imagesc(‘XData’,xLim,’YData’,yLim,’CData’,C.CData);
h_im.AlphaData = 0.5;
hold(ax,’off’)I am having a problem getting a match between a surface plot and an image of the plot. This is possibly to do with NaNs along border and the problem addressed in https://uk.mathworks.com/matlabcentral/answers/484482-surf-and-nan-plotting-bug. However, I have tried a range of adjustments to the axis without success. Any pointers gratefully appreciated. Some sample code and a grid file:
%load the grid
load(‘test_grid’,’-mat’); %load the grid struct
Z = grid.z’;
hf = figure(‘Tag’,’PlotFig’);
ax = axes(hf);
C = pcolor(ax,grid.x,grid.y,Z);
shading interp
axis equal tight
delX = abs(grid.x(2)-grid.x(1));
delY = abs(grid.y(2)-grid.y(1));
xLim = xlim;
yLim = ylim;
%adjusting the x and y limits seems to have no effect on the image plot
yLim(2) = yLim(2)-delY*10;
%overlay a derived image on the original plot
hold(ax,’on’)
h_im = imagesc(‘XData’,xLim,’YData’,yLim,’CData’,C.CData);
h_im.AlphaData = 0.5;
hold(ax,’off’) I am having a problem getting a match between a surface plot and an image of the plot. This is possibly to do with NaNs along border and the problem addressed in https://uk.mathworks.com/matlabcentral/answers/484482-surf-and-nan-plotting-bug. However, I have tried a range of adjustments to the axis without success. Any pointers gratefully appreciated. Some sample code and a grid file:
%load the grid
load(‘test_grid’,’-mat’); %load the grid struct
Z = grid.z’;
hf = figure(‘Tag’,’PlotFig’);
ax = axes(hf);
C = pcolor(ax,grid.x,grid.y,Z);
shading interp
axis equal tight
delX = abs(grid.x(2)-grid.x(1));
delY = abs(grid.y(2)-grid.y(1));
xLim = xlim;
yLim = ylim;
%adjusting the x and y limits seems to have no effect on the image plot
yLim(2) = yLim(2)-delY*10;
%overlay a derived image on the original plot
hold(ax,’on’)
h_im = imagesc(‘XData’,xLim,’YData’,yLim,’CData’,C.CData);
h_im.AlphaData = 0.5;
hold(ax,’off’) imagesc, surface plot, nan data MATLAB Answers — New Questions
Non-Modal uiconfirm/uialert etc.
Is there a way to make the newer style dialog boxes like uiconfirm non modal?
I was using the jFrame method until recently but I am moving my app to a new matlab version where using jFrames directly is deprecated.
Is there a way, apart from making my own dialog boxes, to change the windowStyle? The property is not accessable and I didn’t find a way to get the handle to the dialog box.Is there a way to make the newer style dialog boxes like uiconfirm non modal?
I was using the jFrame method until recently but I am moving my app to a new matlab version where using jFrames directly is deprecated.
Is there a way, apart from making my own dialog boxes, to change the windowStyle? The property is not accessable and I didn’t find a way to get the handle to the dialog box. Is there a way to make the newer style dialog boxes like uiconfirm non modal?
I was using the jFrame method until recently but I am moving my app to a new matlab version where using jFrames directly is deprecated.
Is there a way, apart from making my own dialog boxes, to change the windowStyle? The property is not accessable and I didn’t find a way to get the handle to the dialog box. uiconfirm, uialert, modal, non modal, handles MATLAB Answers — New Questions
How to undo a delete?
How do I undo an accidental delete when using the editor for a .m file, or alternatively retrieve the .m file from before the accidental delete?How do I undo an accidental delete when using the editor for a .m file, or alternatively retrieve the .m file from before the accidental delete? How do I undo an accidental delete when using the editor for a .m file, or alternatively retrieve the .m file from before the accidental delete? editor, undelete MATLAB Answers — New Questions
Generating Gaussian Mixture Model
Hi guys,
I’ve been asked to solve the following exercise, can anyone help?
Define Gaussian mixture models in order to generate data. Use at least 2 classes, in each class use 3 clusters. The data should be generated randomly, both the latent variable and the samples. The data dimension should be at least 3.
Thanks in advanced (:Hi guys,
I’ve been asked to solve the following exercise, can anyone help?
Define Gaussian mixture models in order to generate data. Use at least 2 classes, in each class use 3 clusters. The data should be generated randomly, both the latent variable and the samples. The data dimension should be at least 3.
Thanks in advanced (: Hi guys,
I’ve been asked to solve the following exercise, can anyone help?
Define Gaussian mixture models in order to generate data. Use at least 2 classes, in each class use 3 clusters. The data should be generated randomly, both the latent variable and the samples. The data dimension should be at least 3.
Thanks in advanced (: gmm MATLAB Answers — New Questions
Radially averaged power spectrum coding
What is the coding to generate the 2D graph for radially averaged power spectrumWhat is the coding to generate the 2D graph for radially averaged power spectrum What is the coding to generate the 2D graph for radially averaged power spectrum raps coding MATLAB Answers — New Questions