Author: PuTI
When using bootstrp, are paired variables resampled together?
In looking at the example for bootstrp in the documentation, two variables include lsat and gpa (http://www.mathworks.com/help/stats/bootstrp.html). Do the values for these variables stay paired (the data points are resampled versus each variable is resampled separately)? For instance, if a person has an LSAT score of 115 and a GPA of 3.6, when that data point is resampled subsequently, will 115 and 3.6 stay paired, or are the two variables resampled independently?In looking at the example for bootstrp in the documentation, two variables include lsat and gpa (http://www.mathworks.com/help/stats/bootstrp.html). Do the values for these variables stay paired (the data points are resampled versus each variable is resampled separately)? For instance, if a person has an LSAT score of 115 and a GPA of 3.6, when that data point is resampled subsequently, will 115 and 3.6 stay paired, or are the two variables resampled independently? In looking at the example for bootstrp in the documentation, two variables include lsat and gpa (http://www.mathworks.com/help/stats/bootstrp.html). Do the values for these variables stay paired (the data points are resampled versus each variable is resampled separately)? For instance, if a person has an LSAT score of 115 and a GPA of 3.6, when that data point is resampled subsequently, will 115 and 3.6 stay paired, or are the two variables resampled independently? statistics, bootstrap MATLAB Answers — New Questions
Desktop window log out before open it
few day before, i was unable to open desktop window on PC. I have tried any answer form Math Work, but still failed. than i decided to reinstall the computer and installed again. After installed desktop window, i logged my friend’s account (cause i can’t recive the verify mail). Everything is down.
here is the problem
if my desktop window can open is system promblem, which is easy to slove.
What if the problem is the account verify fail cause desktop window don’t show up. How to log out my account before open Matlab desktop window ?few day before, i was unable to open desktop window on PC. I have tried any answer form Math Work, but still failed. than i decided to reinstall the computer and installed again. After installed desktop window, i logged my friend’s account (cause i can’t recive the verify mail). Everything is down.
here is the problem
if my desktop window can open is system promblem, which is easy to slove.
What if the problem is the account verify fail cause desktop window don’t show up. How to log out my account before open Matlab desktop window ? few day before, i was unable to open desktop window on PC. I have tried any answer form Math Work, but still failed. than i decided to reinstall the computer and installed again. After installed desktop window, i logged my friend’s account (cause i can’t recive the verify mail). Everything is down.
here is the problem
if my desktop window can open is system promblem, which is easy to slove.
What if the problem is the account verify fail cause desktop window don’t show up. How to log out my account before open Matlab desktop window ? log in/out MATLAB Answers — New Questions
Securing Container Workloads on Azure Container Apps (ACA)
Azure Container Apps (ACA) is a serverless platform for scalable containerized applications, while abstracting the underlying infrastructure. Since it runs without providing access to its underlying operating system, it has inherent security benefits, but it also presents a challenge for security and compliance tools that were not purpose-built to support such an environment. Aqua is a certified security solution for ACA – read on to see how we do it.
Azure Container Apps (ACA) is a serverless platform for scalable containerized applications, while abstracting the underlying infrastructure. Since it runs without providing access to its underlying operating system, it has inherent security benefits, but it also presents a challenge for security and compliance tools that were not purpose-built to support such an environment. Aqua is a certified security solution for ACA – read on to see how we do it.
Read More
Plot first terms of Fourier series and amplitude
Hello,
how can I plot the first k terms of a Fourier series on the same graph (without showing the Gibb’s effect). I would also like to plot the amplitude of those terms over frequency. I want the graphs on the attached picture. How can I make them with Matlab?
Thanks in advanceHello,
how can I plot the first k terms of a Fourier series on the same graph (without showing the Gibb’s effect). I would also like to plot the amplitude of those terms over frequency. I want the graphs on the attached picture. How can I make them with Matlab?
Thanks in advance Hello,
how can I plot the first k terms of a Fourier series on the same graph (without showing the Gibb’s effect). I would also like to plot the amplitude of those terms over frequency. I want the graphs on the attached picture. How can I make them with Matlab?
Thanks in advance fourier, plotting MATLAB Answers — New Questions
fminunc step size too small
Hello Matlab community,
I am using fminunc to fit a function to a set of datapoints. The optimizer stops due to small step size however I have noticed the steps it is taking are way too small. I don’t want to set the minimum step size lower than 1e-3 but if I do so it just stops immediately.
The solution I have found is to provide the function with my own calculated gradient and manually multiplying it by 1e6.
Is there an optimizer option that can rescale the step size to gradient ratio in a similar way?
My optimizer options are:
options = optimoptions(‘fminunc’, …
‘Display’, ‘iter’, …
‘Algorithm’, ‘trust-region’, …
‘HessianFcn’,’objective’, …
‘SpecifyObjectiveGradient’,true, …
‘StepTolerance’, 5e-3, …,
"FiniteDifferenceStepSize", 0.1, …,
"FunctionTolerance",0.00001, …
"OptimalityTolerance",2e-6/factor, …
‘MaxFunctionEvaluations’, 10000, …
‘MaxIterations’, 10000, …
‘OutputFcn’, @saveIterations);
Thank you in advance for your help!Hello Matlab community,
I am using fminunc to fit a function to a set of datapoints. The optimizer stops due to small step size however I have noticed the steps it is taking are way too small. I don’t want to set the minimum step size lower than 1e-3 but if I do so it just stops immediately.
The solution I have found is to provide the function with my own calculated gradient and manually multiplying it by 1e6.
Is there an optimizer option that can rescale the step size to gradient ratio in a similar way?
My optimizer options are:
options = optimoptions(‘fminunc’, …
‘Display’, ‘iter’, …
‘Algorithm’, ‘trust-region’, …
‘HessianFcn’,’objective’, …
‘SpecifyObjectiveGradient’,true, …
‘StepTolerance’, 5e-3, …,
"FiniteDifferenceStepSize", 0.1, …,
"FunctionTolerance",0.00001, …
"OptimalityTolerance",2e-6/factor, …
‘MaxFunctionEvaluations’, 10000, …
‘MaxIterations’, 10000, …
‘OutputFcn’, @saveIterations);
Thank you in advance for your help! Hello Matlab community,
I am using fminunc to fit a function to a set of datapoints. The optimizer stops due to small step size however I have noticed the steps it is taking are way too small. I don’t want to set the minimum step size lower than 1e-3 but if I do so it just stops immediately.
The solution I have found is to provide the function with my own calculated gradient and manually multiplying it by 1e6.
Is there an optimizer option that can rescale the step size to gradient ratio in a similar way?
My optimizer options are:
options = optimoptions(‘fminunc’, …
‘Display’, ‘iter’, …
‘Algorithm’, ‘trust-region’, …
‘HessianFcn’,’objective’, …
‘SpecifyObjectiveGradient’,true, …
‘StepTolerance’, 5e-3, …,
"FiniteDifferenceStepSize", 0.1, …,
"FunctionTolerance",0.00001, …
"OptimalityTolerance",2e-6/factor, …
‘MaxFunctionEvaluations’, 10000, …
‘MaxIterations’, 10000, …
‘OutputFcn’, @saveIterations);
Thank you in advance for your help! optimization, fminunc MATLAB Answers — New Questions
Using the command window as a serial monitor for arduino
I want to use the command window as a serial monitor to plot data sent by arduino or another device serially. I need to send some data to arduino too. I have the following code.
% lectura de puerto serial COM
clc;
clear;
close all;
%comandos de apertura del puerto serial
com_avr = serial(‘COM4’,115200);
fopen(com_avr);
while(1)
%para leer
data = readline(com_avr); disp(data); %para leer
data = readline(com_avr); disp(data);
str = input("Send to Arduino: ","s");
val = sscanf(str, "%f");
fprintf(com_avr, "%f", val);
%muestra lo que se envio
data = readline(com_avr); disp(data);
%HERE MUST TO PLOT THE DATA
while 1
data = readline(com_avr);
plot(x,data,’bd’,’LineWidth’,2)
axis([x-2 x 40 160])
hold on
drawnow
x = x + 0.002;
end
%secuencia de comandos de salida
if str == ‘z’
disp("exit")
break;
end
end
disp("closing communication…")
%finaliza la comunicacion serial y libera el puerto
close(com_avr);
What could I do to open a plot graph and plot the data sent from Arduino?
May you give me any sugestion to improve this code?I want to use the command window as a serial monitor to plot data sent by arduino or another device serially. I need to send some data to arduino too. I have the following code.
% lectura de puerto serial COM
clc;
clear;
close all;
%comandos de apertura del puerto serial
com_avr = serial(‘COM4’,115200);
fopen(com_avr);
while(1)
%para leer
data = readline(com_avr); disp(data); %para leer
data = readline(com_avr); disp(data);
str = input("Send to Arduino: ","s");
val = sscanf(str, "%f");
fprintf(com_avr, "%f", val);
%muestra lo que se envio
data = readline(com_avr); disp(data);
%HERE MUST TO PLOT THE DATA
while 1
data = readline(com_avr);
plot(x,data,’bd’,’LineWidth’,2)
axis([x-2 x 40 160])
hold on
drawnow
x = x + 0.002;
end
%secuencia de comandos de salida
if str == ‘z’
disp("exit")
break;
end
end
disp("closing communication…")
%finaliza la comunicacion serial y libera el puerto
close(com_avr);
What could I do to open a plot graph and plot the data sent from Arduino?
May you give me any sugestion to improve this code? I want to use the command window as a serial monitor to plot data sent by arduino or another device serially. I need to send some data to arduino too. I have the following code.
% lectura de puerto serial COM
clc;
clear;
close all;
%comandos de apertura del puerto serial
com_avr = serial(‘COM4’,115200);
fopen(com_avr);
while(1)
%para leer
data = readline(com_avr); disp(data); %para leer
data = readline(com_avr); disp(data);
str = input("Send to Arduino: ","s");
val = sscanf(str, "%f");
fprintf(com_avr, "%f", val);
%muestra lo que se envio
data = readline(com_avr); disp(data);
%HERE MUST TO PLOT THE DATA
while 1
data = readline(com_avr);
plot(x,data,’bd’,’LineWidth’,2)
axis([x-2 x 40 160])
hold on
drawnow
x = x + 0.002;
end
%secuencia de comandos de salida
if str == ‘z’
disp("exit")
break;
end
end
disp("closing communication…")
%finaliza la comunicacion serial y libera el puerto
close(com_avr);
What could I do to open a plot graph and plot the data sent from Arduino?
May you give me any sugestion to improve this code? arduino, serial MATLAB Answers — New Questions
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