Tag Archives: matlab
How to store an array of headers in a MAT file?
I’m trying to update any given table with a new header names imported from a .MAT file. I’m not sure how to approach this. Given the number of columns that the data file has, I want it to access a specific MAT file with new header names so that I can plot the preferred data. I don’t know how to create a mat file within a script so it can save the all the headers names to it as VariableNames and not values.I’m trying to update any given table with a new header names imported from a .MAT file. I’m not sure how to approach this. Given the number of columns that the data file has, I want it to access a specific MAT file with new header names so that I can plot the preferred data. I don’t know how to create a mat file within a script so it can save the all the headers names to it as VariableNames and not values. I’m trying to update any given table with a new header names imported from a .MAT file. I’m not sure how to approach this. Given the number of columns that the data file has, I want it to access a specific MAT file with new header names so that I can plot the preferred data. I don’t know how to create a mat file within a script so it can save the all the headers names to it as VariableNames and not values. matfile, matlab MATLAB Answers — New Questions
patternCustom x axis(Az=0) always assumes first element of the array as x axis
I have a antenna pattern array x=table(gain,theta,phi)
Rotated this array along z axis by adding phi=phi+90
Resultant patternCustom plot gives same figure. When I sort the table ascending with phi I can see expected rotated plot. Is this expected?I have a antenna pattern array x=table(gain,theta,phi)
Rotated this array along z axis by adding phi=phi+90
Resultant patternCustom plot gives same figure. When I sort the table ascending with phi I can see expected rotated plot. Is this expected? I have a antenna pattern array x=table(gain,theta,phi)
Rotated this array along z axis by adding phi=phi+90
Resultant patternCustom plot gives same figure. When I sort the table ascending with phi I can see expected rotated plot. Is this expected? antenna toolbox MATLAB Answers — New Questions
Some indices in indexed images made with cmunique are 0, what does that really mean? Isn’t is a bug? I cannot index a colormap with index=0. Documentation is contradictory.
I transform RGB images to indexed images with cmunique. Some of the indices in the indexed image are 0. It is not mentioned in the help for cmunique, but there is a contradictory statement in the help for rgb2ind, bold in the abbreviated citation below:
"[X,map] = rgb2ind(RGB,n) : Indexed image, returned as an m-by-n matrix X of nonnegative integers. If the length of map is less than or equal to 256, then the output image is of class uint8. Otherwise, the output image is of class uint16. n must be less than or equal to 65,536.
The value 0 in the output array X corresponds to the first color in the colormap."
In my case, the length of smallest color map is of the order of ~1500, so uint16 indices are expected. What do I do with elements of X that are 0 (zero), is there a way to prevent this happening?
Here is my relevant code:
% code snippet
Afull=imread(‘myfigure.png’); % myfigure.png is a color image
rectf=[133 56 521 521];
[fig_xrefout,fig_yrefout,Imfig,rectfig] = imcrop(Afull,rectf);
[Imfig_indexed,fig_map] =cmunique(Imfig);
dum=find(Imfig_indexed<=0);
~isempty(dum) % is 1!!!I transform RGB images to indexed images with cmunique. Some of the indices in the indexed image are 0. It is not mentioned in the help for cmunique, but there is a contradictory statement in the help for rgb2ind, bold in the abbreviated citation below:
"[X,map] = rgb2ind(RGB,n) : Indexed image, returned as an m-by-n matrix X of nonnegative integers. If the length of map is less than or equal to 256, then the output image is of class uint8. Otherwise, the output image is of class uint16. n must be less than or equal to 65,536.
The value 0 in the output array X corresponds to the first color in the colormap."
In my case, the length of smallest color map is of the order of ~1500, so uint16 indices are expected. What do I do with elements of X that are 0 (zero), is there a way to prevent this happening?
Here is my relevant code:
% code snippet
Afull=imread(‘myfigure.png’); % myfigure.png is a color image
rectf=[133 56 521 521];
[fig_xrefout,fig_yrefout,Imfig,rectfig] = imcrop(Afull,rectf);
[Imfig_indexed,fig_map] =cmunique(Imfig);
dum=find(Imfig_indexed<=0);
~isempty(dum) % is 1!!! I transform RGB images to indexed images with cmunique. Some of the indices in the indexed image are 0. It is not mentioned in the help for cmunique, but there is a contradictory statement in the help for rgb2ind, bold in the abbreviated citation below:
"[X,map] = rgb2ind(RGB,n) : Indexed image, returned as an m-by-n matrix X of nonnegative integers. If the length of map is less than or equal to 256, then the output image is of class uint8. Otherwise, the output image is of class uint16. n must be less than or equal to 65,536.
The value 0 in the output array X corresponds to the first color in the colormap."
In my case, the length of smallest color map is of the order of ~1500, so uint16 indices are expected. What do I do with elements of X that are 0 (zero), is there a way to prevent this happening?
Here is my relevant code:
% code snippet
Afull=imread(‘myfigure.png’); % myfigure.png is a color image
rectf=[133 56 521 521];
[fig_xrefout,fig_yrefout,Imfig,rectfig] = imcrop(Afull,rectf);
[Imfig_indexed,fig_map] =cmunique(Imfig);
dum=find(Imfig_indexed<=0);
~isempty(dum) % is 1!!! cmunique, value 0, indexed image MATLAB Answers — New Questions
Unrecognized function or variable ‘rlContinuousDeterministicActorRepresentation’
Hello, This is my code
%clc
%clear all
rng(0)
% Load MATPOWER case
mpc = loadcase(‘case118’);
% Create the environment
env = createOpfEnv();
import matlab.rl.*
% Define SAC agent
actorNetwork = [
featureInputLayer(obsInfo.Dimension(1))
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(actInfo.Dimension(1))
];
criticNetwork = [
featureInputLayer([obsInfo.Dimension(1) + actInfo.Dimension(1)])
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(1)
];
actorOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-4);
criticOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-4);
actor = rlContinuousDeterministicActorRepresentation(actorNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, actorOptions);
critic = rlQValueRepresentation(criticNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, criticOptions);
agentOptions = rlSACAgentOptions(‘SampleTime’, 1, ‘TargetSmoothFactor’, 1e-3, ‘TargetUpdateFrequency’, 1, ‘ExperienceBufferLength’, 1e6);
agent = rlSACAgent(actor, critic, agentOptions);
% Training options
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’, 1000, …
‘MaxStepsPerEpisode’, 100, …
‘StopTrainingCriteria’, ‘AverageReward’, …
‘StopTrainingValue’, -100, …
‘ScoreAveragingWindowLength’, 10, …
‘Verbose’, true, …
‘Plots’, ‘training-progress’);
% Train the agent
train(agent, env, trainOpts);
and when i tried running i got the error "Error in DRL_code (line 32)
actor = rlContinuousDeterministicActorRepresentation(actorNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, actorOptions);"
I am using MATLAB 2024AHello, This is my code
%clc
%clear all
rng(0)
% Load MATPOWER case
mpc = loadcase(‘case118’);
% Create the environment
env = createOpfEnv();
import matlab.rl.*
% Define SAC agent
actorNetwork = [
featureInputLayer(obsInfo.Dimension(1))
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(actInfo.Dimension(1))
];
criticNetwork = [
featureInputLayer([obsInfo.Dimension(1) + actInfo.Dimension(1)])
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(1)
];
actorOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-4);
criticOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-4);
actor = rlContinuousDeterministicActorRepresentation(actorNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, actorOptions);
critic = rlQValueRepresentation(criticNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, criticOptions);
agentOptions = rlSACAgentOptions(‘SampleTime’, 1, ‘TargetSmoothFactor’, 1e-3, ‘TargetUpdateFrequency’, 1, ‘ExperienceBufferLength’, 1e6);
agent = rlSACAgent(actor, critic, agentOptions);
% Training options
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’, 1000, …
‘MaxStepsPerEpisode’, 100, …
‘StopTrainingCriteria’, ‘AverageReward’, …
‘StopTrainingValue’, -100, …
‘ScoreAveragingWindowLength’, 10, …
‘Verbose’, true, …
‘Plots’, ‘training-progress’);
% Train the agent
train(agent, env, trainOpts);
and when i tried running i got the error "Error in DRL_code (line 32)
actor = rlContinuousDeterministicActorRepresentation(actorNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, actorOptions);"
I am using MATLAB 2024A Hello, This is my code
%clc
%clear all
rng(0)
% Load MATPOWER case
mpc = loadcase(‘case118’);
% Create the environment
env = createOpfEnv();
import matlab.rl.*
% Define SAC agent
actorNetwork = [
featureInputLayer(obsInfo.Dimension(1))
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(actInfo.Dimension(1))
];
criticNetwork = [
featureInputLayer([obsInfo.Dimension(1) + actInfo.Dimension(1)])
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(64)
reluLayer
fullyConnectedLayer(1)
];
actorOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-4);
criticOptions = rlRepresentationOptions(‘Optimizer’,’adam’,’LearnRate’,1e-4);
actor = rlContinuousDeterministicActorRepresentation(actorNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, actorOptions);
critic = rlQValueRepresentation(criticNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, criticOptions);
agentOptions = rlSACAgentOptions(‘SampleTime’, 1, ‘TargetSmoothFactor’, 1e-3, ‘TargetUpdateFrequency’, 1, ‘ExperienceBufferLength’, 1e6);
agent = rlSACAgent(actor, critic, agentOptions);
% Training options
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’, 1000, …
‘MaxStepsPerEpisode’, 100, …
‘StopTrainingCriteria’, ‘AverageReward’, …
‘StopTrainingValue’, -100, …
‘ScoreAveragingWindowLength’, 10, …
‘Verbose’, true, …
‘Plots’, ‘training-progress’);
% Train the agent
train(agent, env, trainOpts);
and when i tried running i got the error "Error in DRL_code (line 32)
actor = rlContinuousDeterministicActorRepresentation(actorNetwork, obsInfo, actInfo, ‘Observation’, {‘observations’}, ‘Action’, {‘actions’}, actorOptions);"
I am using MATLAB 2024A reinforcement learning MATLAB Answers — New Questions
PRCC sensitive analysis graphs
I have tried to get prcc sensitve analysis graph, but unfortunately i got an error.I request you please help to overcome the error.
CODE:
% Define parameter ranges
paramRanges = struct(‘beta’, [0.1, 0.5], ‘sigma’, [0.1, 0.3], ‘gamma’, [0.1, 0.4]);
% Number of samples
nSamples = 100;
% Number of parameters
paramNames = fieldnames(paramRanges);
nParams = numel(paramNames);
% Generate LHS samples
lhsSamples = lhsdesign(nSamples, nParams);
% Scale samples to parameter ranges
scaledSamples = zeros(nSamples, nParams);
for i = 1:nParams
low = paramRanges.(paramNames{i})(1);
high = paramRanges.(paramNames{i})(2);
scaledSamples(:, i) = low + lhsSamples(:, i) * (high – low);
end
% Define SEIR model parameters and calculate R0
% Run simulations to compute R0 for each parameter set
R0Values = zeros(nSamples, 1);
for i = 1:nSamples
R0Values(i) = calculateR0(scaledSamples(i, :));
end
% Calculate PRCC
function prcc = calculatePRCC(outputs, samples)
nParams = size(samples, 2);
prcc = zeros(nParams, 1);
for i = 1:nParams
% Rank data
ranksSamples = tiedrank(samples(:, i));
ranksOutputs = tiedrank(outputs);
% Compute correlation
prcc(i) = corr(ranksSamples, ranksOutputs);
end
end
% Perform PRCC analysis for R0 values
prccValues = calculatePRCC(R0Values, scaledSamples);
function R0 = calculateR0(params)
beta = params(1);
sigma = params(2);
gamma = params(3);
% Basic reproduction number for SEIR model
R0 = beta / gamma;
end
% Display results
for i = 1:nParams
fprintf(‘PRCC for %s: %.4fn’, paramNames{i}, prccValues(i));
end
ERROR:
Function definitions in a script must appear at the end of the file.
Move all statements after the "calculateR0" function definition to before the first local function definition.I have tried to get prcc sensitve analysis graph, but unfortunately i got an error.I request you please help to overcome the error.
CODE:
% Define parameter ranges
paramRanges = struct(‘beta’, [0.1, 0.5], ‘sigma’, [0.1, 0.3], ‘gamma’, [0.1, 0.4]);
% Number of samples
nSamples = 100;
% Number of parameters
paramNames = fieldnames(paramRanges);
nParams = numel(paramNames);
% Generate LHS samples
lhsSamples = lhsdesign(nSamples, nParams);
% Scale samples to parameter ranges
scaledSamples = zeros(nSamples, nParams);
for i = 1:nParams
low = paramRanges.(paramNames{i})(1);
high = paramRanges.(paramNames{i})(2);
scaledSamples(:, i) = low + lhsSamples(:, i) * (high – low);
end
% Define SEIR model parameters and calculate R0
% Run simulations to compute R0 for each parameter set
R0Values = zeros(nSamples, 1);
for i = 1:nSamples
R0Values(i) = calculateR0(scaledSamples(i, :));
end
% Calculate PRCC
function prcc = calculatePRCC(outputs, samples)
nParams = size(samples, 2);
prcc = zeros(nParams, 1);
for i = 1:nParams
% Rank data
ranksSamples = tiedrank(samples(:, i));
ranksOutputs = tiedrank(outputs);
% Compute correlation
prcc(i) = corr(ranksSamples, ranksOutputs);
end
end
% Perform PRCC analysis for R0 values
prccValues = calculatePRCC(R0Values, scaledSamples);
function R0 = calculateR0(params)
beta = params(1);
sigma = params(2);
gamma = params(3);
% Basic reproduction number for SEIR model
R0 = beta / gamma;
end
% Display results
for i = 1:nParams
fprintf(‘PRCC for %s: %.4fn’, paramNames{i}, prccValues(i));
end
ERROR:
Function definitions in a script must appear at the end of the file.
Move all statements after the "calculateR0" function definition to before the first local function definition. I have tried to get prcc sensitve analysis graph, but unfortunately i got an error.I request you please help to overcome the error.
CODE:
% Define parameter ranges
paramRanges = struct(‘beta’, [0.1, 0.5], ‘sigma’, [0.1, 0.3], ‘gamma’, [0.1, 0.4]);
% Number of samples
nSamples = 100;
% Number of parameters
paramNames = fieldnames(paramRanges);
nParams = numel(paramNames);
% Generate LHS samples
lhsSamples = lhsdesign(nSamples, nParams);
% Scale samples to parameter ranges
scaledSamples = zeros(nSamples, nParams);
for i = 1:nParams
low = paramRanges.(paramNames{i})(1);
high = paramRanges.(paramNames{i})(2);
scaledSamples(:, i) = low + lhsSamples(:, i) * (high – low);
end
% Define SEIR model parameters and calculate R0
% Run simulations to compute R0 for each parameter set
R0Values = zeros(nSamples, 1);
for i = 1:nSamples
R0Values(i) = calculateR0(scaledSamples(i, :));
end
% Calculate PRCC
function prcc = calculatePRCC(outputs, samples)
nParams = size(samples, 2);
prcc = zeros(nParams, 1);
for i = 1:nParams
% Rank data
ranksSamples = tiedrank(samples(:, i));
ranksOutputs = tiedrank(outputs);
% Compute correlation
prcc(i) = corr(ranksSamples, ranksOutputs);
end
end
% Perform PRCC analysis for R0 values
prccValues = calculatePRCC(R0Values, scaledSamples);
function R0 = calculateR0(params)
beta = params(1);
sigma = params(2);
gamma = params(3);
% Basic reproduction number for SEIR model
R0 = beta / gamma;
end
% Display results
for i = 1:nParams
fprintf(‘PRCC for %s: %.4fn’, paramNames{i}, prccValues(i));
end
ERROR:
Function definitions in a script must appear at the end of the file.
Move all statements after the "calculateR0" function definition to before the first local function definition. prcc, sensitive analysis MATLAB Answers — New Questions
How can i access to simulink’s ‘vco_testbench’block source code? Is it impossible?
How can i access to simulink’s ‘vco_testbench’block source code? Is it impossible?How can i access to simulink’s ‘vco_testbench’block source code? Is it impossible? How can i access to simulink’s ‘vco_testbench’block source code? Is it impossible? vco, testbench, source MATLAB Answers — New Questions
Trail Version – Invalid Activation Key(379)
I am trying to use the trail version but I am getting this Invalid Activation Key (379) error.
I just created a new gmail for the trail and never installed on any other device. I created matlab account and downloaded the trail version installer which gave me this error when trying to login to installI am trying to use the trail version but I am getting this Invalid Activation Key (379) error.
I just created a new gmail for the trail and never installed on any other device. I created matlab account and downloaded the trail version installer which gave me this error when trying to login to install I am trying to use the trail version but I am getting this Invalid Activation Key (379) error.
I just created a new gmail for the trail and never installed on any other device. I created matlab account and downloaded the trail version installer which gave me this error when trying to login to install trail, invalid licence key, 379, error 379 MATLAB Answers — New Questions
How correctly use Simple Variable Mass 3DOF (Body Axes) block?
Hello,
As in the title, I need to simulate an aircraft mission with varying mass. In the Aerospace Blockset, I’ve so found the Simple Variable Mass (3DOF). I have some problems in interpreting these inertia definitions:
Empty inertia — Body inertia when fuel tank is full
0.5 (default) | scalar
Body inertia when the fuel tank is full, specified as a double scalar.
and
Full inertia — Full inertia
3.0 (default) | scalar
Full inertia of the body, specified as a scalar.
My concerns involves the difference between Empty and full inertia. From the documentation, they seem to be the same. Can anyone help me?
Thanks.Hello,
As in the title, I need to simulate an aircraft mission with varying mass. In the Aerospace Blockset, I’ve so found the Simple Variable Mass (3DOF). I have some problems in interpreting these inertia definitions:
Empty inertia — Body inertia when fuel tank is full
0.5 (default) | scalar
Body inertia when the fuel tank is full, specified as a double scalar.
and
Full inertia — Full inertia
3.0 (default) | scalar
Full inertia of the body, specified as a scalar.
My concerns involves the difference between Empty and full inertia. From the documentation, they seem to be the same. Can anyone help me?
Thanks. Hello,
As in the title, I need to simulate an aircraft mission with varying mass. In the Aerospace Blockset, I’ve so found the Simple Variable Mass (3DOF). I have some problems in interpreting these inertia definitions:
Empty inertia — Body inertia when fuel tank is full
0.5 (default) | scalar
Body inertia when the fuel tank is full, specified as a double scalar.
and
Full inertia — Full inertia
3.0 (default) | scalar
Full inertia of the body, specified as a scalar.
My concerns involves the difference between Empty and full inertia. From the documentation, they seem to be the same. Can anyone help me?
Thanks. 3dof, varying mass, aerospace, simulink, simulation MATLAB Answers — New Questions
Simulink Variable Time Logging
Hi,
is it possible to get a simulink "to workspace" block to log the data with variable time steps? I have a model in which some parameters are used to send it to hardware and the testrig is basically controlled with my model. For some commands I send to the testrig it is not really useful to have the logged within the sample time I have for my model, for example some preparation steps when I change the temperature, which could take quite long. I tried to have the different sample times in a varaible in the base workspace and after the command in simulink/ stateflow is processed the variable is changed. I had the variable of the sample time in my "to workspace" block, and it seemed to work sometimes to refresh the block and it changed to a new sample time, but it kept it that way for the whole simulation. Do you have any suggestions on how I could do this or maybe a better way to do this?Hi,
is it possible to get a simulink "to workspace" block to log the data with variable time steps? I have a model in which some parameters are used to send it to hardware and the testrig is basically controlled with my model. For some commands I send to the testrig it is not really useful to have the logged within the sample time I have for my model, for example some preparation steps when I change the temperature, which could take quite long. I tried to have the different sample times in a varaible in the base workspace and after the command in simulink/ stateflow is processed the variable is changed. I had the variable of the sample time in my "to workspace" block, and it seemed to work sometimes to refresh the block and it changed to a new sample time, but it kept it that way for the whole simulation. Do you have any suggestions on how I could do this or maybe a better way to do this? Hi,
is it possible to get a simulink "to workspace" block to log the data with variable time steps? I have a model in which some parameters are used to send it to hardware and the testrig is basically controlled with my model. For some commands I send to the testrig it is not really useful to have the logged within the sample time I have for my model, for example some preparation steps when I change the temperature, which could take quite long. I tried to have the different sample times in a varaible in the base workspace and after the command in simulink/ stateflow is processed the variable is changed. I had the variable of the sample time in my "to workspace" block, and it seemed to work sometimes to refresh the block and it changed to a new sample time, but it kept it that way for the whole simulation. Do you have any suggestions on how I could do this or maybe a better way to do this? variable logging time, sample time, simulink MATLAB Answers — New Questions
Robot arms 3RRR Kinematics and forward kinematics
Hey i need a help or some file with Kinematics and forward kinematics for
manipulator arm i mean 3RRR
i will really happy when someone can help me
wait for answerHey i need a help or some file with Kinematics and forward kinematics for
manipulator arm i mean 3RRR
i will really happy when someone can help me
wait for answer Hey i need a help or some file with Kinematics and forward kinematics for
manipulator arm i mean 3RRR
i will really happy when someone can help me
wait for answer rrr, kinematics, 3rrr, forward kinematics, rrr kinematics matlab MATLAB Answers — New Questions
acousticLoudness() function incorrect?
I decided to verify acousticLoudness function using ISO532-1 test method using ISO provided test signals and compare to stated sone levels.
According to ISO532-1 test signal wav data should be calibrated: " For the calibration of the WAVE files, 0 dB (relative to full scale) shall correspond to a sound pressure level of 100 dB." The calibration factor works out to be =2. This could be immediately verified by comparing test frequency amplitude after calibration with file name e.g. "Test signal 6 (tone 250 Hz 30 dB – 80 dB).wav". The max amplitude is 0.2 Pa (80dB).
I used these function parameters to calculate loudness of time varying noise signals:
LoudnessISO532=acousticLoudness(signal,48000,’SoundField’,’free’,’TimeVarying’,true);
acousticLoudness() produces loudness nearly twice the value of the ISO calculation. I discovered, however, that if I do not calibrate the wav file, function produces correct results.
Thus, it seems to me, to obtain correct results, calibrated SPL (Pa) signal should be reduced by half.
Did anybody try to verify the function using ISO532-1 test wav files? Did you calibrate them?
Thanks!I decided to verify acousticLoudness function using ISO532-1 test method using ISO provided test signals and compare to stated sone levels.
According to ISO532-1 test signal wav data should be calibrated: " For the calibration of the WAVE files, 0 dB (relative to full scale) shall correspond to a sound pressure level of 100 dB." The calibration factor works out to be =2. This could be immediately verified by comparing test frequency amplitude after calibration with file name e.g. "Test signal 6 (tone 250 Hz 30 dB – 80 dB).wav". The max amplitude is 0.2 Pa (80dB).
I used these function parameters to calculate loudness of time varying noise signals:
LoudnessISO532=acousticLoudness(signal,48000,’SoundField’,’free’,’TimeVarying’,true);
acousticLoudness() produces loudness nearly twice the value of the ISO calculation. I discovered, however, that if I do not calibrate the wav file, function produces correct results.
Thus, it seems to me, to obtain correct results, calibrated SPL (Pa) signal should be reduced by half.
Did anybody try to verify the function using ISO532-1 test wav files? Did you calibrate them?
Thanks! I decided to verify acousticLoudness function using ISO532-1 test method using ISO provided test signals and compare to stated sone levels.
According to ISO532-1 test signal wav data should be calibrated: " For the calibration of the WAVE files, 0 dB (relative to full scale) shall correspond to a sound pressure level of 100 dB." The calibration factor works out to be =2. This could be immediately verified by comparing test frequency amplitude after calibration with file name e.g. "Test signal 6 (tone 250 Hz 30 dB – 80 dB).wav". The max amplitude is 0.2 Pa (80dB).
I used these function parameters to calculate loudness of time varying noise signals:
LoudnessISO532=acousticLoudness(signal,48000,’SoundField’,’free’,’TimeVarying’,true);
acousticLoudness() produces loudness nearly twice the value of the ISO calculation. I discovered, however, that if I do not calibrate the wav file, function produces correct results.
Thus, it seems to me, to obtain correct results, calibrated SPL (Pa) signal should be reduced by half.
Did anybody try to verify the function using ISO532-1 test wav files? Did you calibrate them?
Thanks! acousticloudness MATLAB Answers — New Questions
Is it possible to remove 2-3 endmember spectral lines from a spectral plot, and how?
I plotted a spectral plot of 9 endmembers, from this I need to remove spectral lines 2, 4 and 5 or select other lines.
.I plotted a spectral plot of 9 endmembers, from this I need to remove spectral lines 2, 4 and 5 or select other lines.
. I plotted a spectral plot of 9 endmembers, from this I need to remove spectral lines 2, 4 and 5 or select other lines.
. hyperspectral image processing MATLAB Answers — New Questions
Write script matlab for solving the convection-diffusion equation of a compound in a 3D annular reactor (diffusion in two directions with convection)
hello,
I would like help to write a matlab for solving the convection-diffusion equation of a compound in a 3D annular reactor (diffusion in two directions r and teta with convective transport in the main direction, see figure below) with a reaction on the surface of inner cylinder. The elements of the problem are as follows:
a 3D model is proposed. This model is based on a convection / radial diffusion principle in the annular space of the reactor. The mass balance in the gas phase can be written (eq. (1)):
(1)
0 < z < L
Inlet concentration : C0=4.5 10-5 mol.m-3
Where r is radial coordinate (m), z is axial coordinate, u is flow velocity (m s-1) and C, is the concentration of NCl3 (mol m-3).
The model takes the velocity profile developed in the annular space into account, as expressed by the following relationship:
(2)
With
(3)
z=1m
Um=0.5m s-1
ri=0.04m, the internal radius
re=0.05m, the external radius of reactor (m).
Boundary conditions are:
at the inner surface of the external cylinder, r=re:
(4)
at the catalyst surface, r=ri,
(5)
Where rp is the photocatalytic rate (mol m-2 s-1).
(6)
I=9.8 W m-2, n =1, kp = 2.6×10-6 mol s-1 W-1and Kp = 3x103m3 mol-1.
and for and
Thank you very much for your helphello,
I would like help to write a matlab for solving the convection-diffusion equation of a compound in a 3D annular reactor (diffusion in two directions r and teta with convective transport in the main direction, see figure below) with a reaction on the surface of inner cylinder. The elements of the problem are as follows:
a 3D model is proposed. This model is based on a convection / radial diffusion principle in the annular space of the reactor. The mass balance in the gas phase can be written (eq. (1)):
(1)
0 < z < L
Inlet concentration : C0=4.5 10-5 mol.m-3
Where r is radial coordinate (m), z is axial coordinate, u is flow velocity (m s-1) and C, is the concentration of NCl3 (mol m-3).
The model takes the velocity profile developed in the annular space into account, as expressed by the following relationship:
(2)
With
(3)
z=1m
Um=0.5m s-1
ri=0.04m, the internal radius
re=0.05m, the external radius of reactor (m).
Boundary conditions are:
at the inner surface of the external cylinder, r=re:
(4)
at the catalyst surface, r=ri,
(5)
Where rp is the photocatalytic rate (mol m-2 s-1).
(6)
I=9.8 W m-2, n =1, kp = 2.6×10-6 mol s-1 W-1and Kp = 3x103m3 mol-1.
and for and
Thank you very much for your help hello,
I would like help to write a matlab for solving the convection-diffusion equation of a compound in a 3D annular reactor (diffusion in two directions r and teta with convective transport in the main direction, see figure below) with a reaction on the surface of inner cylinder. The elements of the problem are as follows:
a 3D model is proposed. This model is based on a convection / radial diffusion principle in the annular space of the reactor. The mass balance in the gas phase can be written (eq. (1)):
(1)
0 < z < L
Inlet concentration : C0=4.5 10-5 mol.m-3
Where r is radial coordinate (m), z is axial coordinate, u is flow velocity (m s-1) and C, is the concentration of NCl3 (mol m-3).
The model takes the velocity profile developed in the annular space into account, as expressed by the following relationship:
(2)
With
(3)
z=1m
Um=0.5m s-1
ri=0.04m, the internal radius
re=0.05m, the external radius of reactor (m).
Boundary conditions are:
at the inner surface of the external cylinder, r=re:
(4)
at the catalyst surface, r=ri,
(5)
Where rp is the photocatalytic rate (mol m-2 s-1).
(6)
I=9.8 W m-2, n =1, kp = 2.6×10-6 mol s-1 W-1and Kp = 3x103m3 mol-1.
and for and
Thank you very much for your help convection_diffusin model, annular reactor 3d MATLAB Answers — New Questions
How to create 3D contour plot of a set of data consisting of series of points x,y,z with a quantity V(x,yz)?
I have a set of data consisting of coordinates x,y,z and the value of a quantity V at each of these points.
like
x,y,z,V
1,3,5,9
3,5,7,-9
……
-4,6,2,1
I need to plot contours of V at the coordinates x,y,z. the number of different x values is NOT equal to the number of different y values.
Any help would be appriciated.
Thank youI have a set of data consisting of coordinates x,y,z and the value of a quantity V at each of these points.
like
x,y,z,V
1,3,5,9
3,5,7,-9
……
-4,6,2,1
I need to plot contours of V at the coordinates x,y,z. the number of different x values is NOT equal to the number of different y values.
Any help would be appriciated.
Thank you I have a set of data consisting of coordinates x,y,z and the value of a quantity V at each of these points.
like
x,y,z,V
1,3,5,9
3,5,7,-9
……
-4,6,2,1
I need to plot contours of V at the coordinates x,y,z. the number of different x values is NOT equal to the number of different y values.
Any help would be appriciated.
Thank you contour, 3d plots MATLAB Answers — New Questions
How do I get num, txt and raw as a cell array or matrix or table from the “readtable(file_name)” command, without using “[num,txt,raw]=xlsread(file_name)”
How do I get num, txt and raw as a cell array/matrix/table from the “readtable(file_name)” command. The alternative command “[num,txt,raw]=xlsread(file_name)” couldn’t be used as it is not recommended by Matlab and requires basic excel (which is decommissioned in our company). So please guide me in this case, Thankyou.
[num,txt,raw] = xlsread(___): num returns the numeric data in a matrix. additionally returns the text fields in cell array txt, and both numeric and text data in cell array raw.How do I get num, txt and raw as a cell array/matrix/table from the “readtable(file_name)” command. The alternative command “[num,txt,raw]=xlsread(file_name)” couldn’t be used as it is not recommended by Matlab and requires basic excel (which is decommissioned in our company). So please guide me in this case, Thankyou.
[num,txt,raw] = xlsread(___): num returns the numeric data in a matrix. additionally returns the text fields in cell array txt, and both numeric and text data in cell array raw. How do I get num, txt and raw as a cell array/matrix/table from the “readtable(file_name)” command. The alternative command “[num,txt,raw]=xlsread(file_name)” couldn’t be used as it is not recommended by Matlab and requires basic excel (which is decommissioned in our company). So please guide me in this case, Thankyou.
[num,txt,raw] = xlsread(___): num returns the numeric data in a matrix. additionally returns the text fields in cell array txt, and both numeric and text data in cell array raw. readtable, xlsread, importing excel data MATLAB Answers — New Questions
How to set timeout to a function
Hi everyone, I need to stop the execution of a function if finish a specific time. Specifically the part of the program where i need to implement it is when i call a function to create a regressor:
[trainedModel, validationRMSE] = trainRegressionModelLinear(T, KFolds);
I have left the program running and it never finish the function so i wanted to exit the function and continue the rest of the program. The function works because i change the data "T" that i insert in the function and i get a trainedModel with its value but with long data T i think no works.
There is a example that i need to do but with try- catch doesnt work:
try
[trainedModel, validationRMSE] = trainRegressionModelLinear(T, KFolds);
catch (*time out finish*)
validationRMSE = "Error";
trainedModel = [];
end
I find some information how said that i need to use parallel pool, batch(), parfeval() or a timer but i dont understand what function is useful for my situation. I already use parallel pool with 4 workers because is better to train regressor but to apply the time out no idea.
Thanks so much for the help and sorry if I have explained badly because the english is not my native language.Hi everyone, I need to stop the execution of a function if finish a specific time. Specifically the part of the program where i need to implement it is when i call a function to create a regressor:
[trainedModel, validationRMSE] = trainRegressionModelLinear(T, KFolds);
I have left the program running and it never finish the function so i wanted to exit the function and continue the rest of the program. The function works because i change the data "T" that i insert in the function and i get a trainedModel with its value but with long data T i think no works.
There is a example that i need to do but with try- catch doesnt work:
try
[trainedModel, validationRMSE] = trainRegressionModelLinear(T, KFolds);
catch (*time out finish*)
validationRMSE = "Error";
trainedModel = [];
end
I find some information how said that i need to use parallel pool, batch(), parfeval() or a timer but i dont understand what function is useful for my situation. I already use parallel pool with 4 workers because is better to train regressor but to apply the time out no idea.
Thanks so much for the help and sorry if I have explained badly because the english is not my native language. Hi everyone, I need to stop the execution of a function if finish a specific time. Specifically the part of the program where i need to implement it is when i call a function to create a regressor:
[trainedModel, validationRMSE] = trainRegressionModelLinear(T, KFolds);
I have left the program running and it never finish the function so i wanted to exit the function and continue the rest of the program. The function works because i change the data "T" that i insert in the function and i get a trainedModel with its value but with long data T i think no works.
There is a example that i need to do but with try- catch doesnt work:
try
[trainedModel, validationRMSE] = trainRegressionModelLinear(T, KFolds);
catch (*time out finish*)
validationRMSE = "Error";
trainedModel = [];
end
I find some information how said that i need to use parallel pool, batch(), parfeval() or a timer but i dont understand what function is useful for my situation. I already use parallel pool with 4 workers because is better to train regressor but to apply the time out no idea.
Thanks so much for the help and sorry if I have explained badly because the english is not my native language. time, regressor, time out, timer, train regressor MATLAB Answers — New Questions
How to control PWM servo driver for arduino from Simulink?
I’m looking for libraries/support to control a PWM driver module (PCA9685) connected to arduino from Simulink. I’m not very skilled with the Arduino add on, so I don’t really know how to send I2C commands to the module fromSimulink.I’m looking for libraries/support to control a PWM driver module (PCA9685) connected to arduino from Simulink. I’m not very skilled with the Arduino add on, so I don’t really know how to send I2C commands to the module fromSimulink. I’m looking for libraries/support to control a PWM driver module (PCA9685) connected to arduino from Simulink. I’m not very skilled with the Arduino add on, so I don’t really know how to send I2C commands to the module fromSimulink. pca9685, simulink MATLAB Answers — New Questions
Is there any command for .xlsx file to import directly to Signal Builder.
I have some inputs recived from user in .xlsx file need to import it into Signal Builder using commands. It can be done manually but i need it with commands which can be done automatically.
Steps:
a. xlsx file needs to be imported from other folders of Desktop.
b. While importing .xlsx file which needs path.
c. Then it should select sheets and replace existing data–> apply –> ok.I have some inputs recived from user in .xlsx file need to import it into Signal Builder using commands. It can be done manually but i need it with commands which can be done automatically.
Steps:
a. xlsx file needs to be imported from other folders of Desktop.
b. While importing .xlsx file which needs path.
c. Then it should select sheets and replace existing data–> apply –> ok. I have some inputs recived from user in .xlsx file need to import it into Signal Builder using commands. It can be done manually but i need it with commands which can be done automatically.
Steps:
a. xlsx file needs to be imported from other folders of Desktop.
b. While importing .xlsx file which needs path.
c. Then it should select sheets and replace existing data–> apply –> ok. m-scripting, signal builder, simulink, matlab MATLAB Answers — New Questions
tic toc delayed output inside for loop
I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration?I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration? I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration? timing, for loop MATLAB Answers — New Questions
How to log out of matlab drive account?
I have two matlab accounts and two PCs, each PC with an account. Recently I need to synchronize my m files, so I tried to use matlab drive. I logged out of my first account from one PC and logged in another one, but the account on matlab drive (which should also log out) remained unchanged even if I had restarted the PC. There also seems no setup on Matlab Connector for log in and out.I have two matlab accounts and two PCs, each PC with an account. Recently I need to synchronize my m files, so I tried to use matlab drive. I logged out of my first account from one PC and logged in another one, but the account on matlab drive (which should also log out) remained unchanged even if I had restarted the PC. There also seems no setup on Matlab Connector for log in and out. I have two matlab accounts and two PCs, each PC with an account. Recently I need to synchronize my m files, so I tried to use matlab drive. I logged out of my first account from one PC and logged in another one, but the account on matlab drive (which should also log out) remained unchanged even if I had restarted the PC. There also seems no setup on Matlab Connector for log in and out. matlab drive, account, matlab connector MATLAB Answers — New Questions