Tag Archives: matlab
How to color values in corrplot function?
Hello,
I created a corrplot with the fisheriris dataset.
I wanted to add a 3rd dimension in the corrplot coloring the values to the corresponding species, like in the following plot.
Is this possible in Matlab?
Thanks for the help and all the best!Hello,
I created a corrplot with the fisheriris dataset.
I wanted to add a 3rd dimension in the corrplot coloring the values to the corresponding species, like in the following plot.
Is this possible in Matlab?
Thanks for the help and all the best! Hello,
I created a corrplot with the fisheriris dataset.
I wanted to add a 3rd dimension in the corrplot coloring the values to the corresponding species, like in the following plot.
Is this possible in Matlab?
Thanks for the help and all the best! corrplot, plotting MATLAB Answers — New Questions
Model unable to output any successful draws in Gibbs sampling
I am trying to estimate a structural VAR model using traditional sign and zero restrictions for the identification of shocks and Minnesota priors. When I adapt the (working) code to run on my data, I am unable to generate any successful draws in the Gibbs sampling phase. I have tried playing around with the settings of the Minnesota prior, as well as number of observations, number of variables, number of restrictions, running the model in First-Differences, and still can’t get any successful draws. Does anyone have any ideas as to why this might be happening or anything I can try next?
Thanks in advance,
AlexI am trying to estimate a structural VAR model using traditional sign and zero restrictions for the identification of shocks and Minnesota priors. When I adapt the (working) code to run on my data, I am unable to generate any successful draws in the Gibbs sampling phase. I have tried playing around with the settings of the Minnesota prior, as well as number of observations, number of variables, number of restrictions, running the model in First-Differences, and still can’t get any successful draws. Does anyone have any ideas as to why this might be happening or anything I can try next?
Thanks in advance,
Alex I am trying to estimate a structural VAR model using traditional sign and zero restrictions for the identification of shocks and Minnesota priors. When I adapt the (working) code to run on my data, I am unable to generate any successful draws in the Gibbs sampling phase. I have tried playing around with the settings of the Minnesota prior, as well as number of observations, number of variables, number of restrictions, running the model in First-Differences, and still can’t get any successful draws. Does anyone have any ideas as to why this might be happening or anything I can try next?
Thanks in advance,
Alex time series, svar model, economics MATLAB Answers — New Questions
Error imposing space-derivative-dependent boundary condition with solvepde using variable state.uy – Error: Unrecognized field name “uy”.
I would appreciate any advice of the following. I am working with PDE Tool box solvepde and a 2d membrane simulation and struggling to impose a spatial-derivative-dependent absorbing a boundary condition on an edge. I am following PDE Toolbox documentation trying two different methods, one (commented out) below using a simple anonymous function and another using a matlab function. These methods work with variables like location.x, location.y, and state.time but seem to fail me with the spatial derivatives. Here is the code snippet in the setup preamble to calling solvepde:
case 3
alpha_absorb=1;beta_absorb=0.0;
m3=m_func(0,ribbonlength/2);
c3=c_func(0,ribbonlength/2);
v3=sqrt(c3(3)/m3);
% my_g= @(location, state,alpha,beta) (-alpha_y *v3.* state.uy +beta_y*state.uyy);
%
% g=@(location,state)(-alpha_y *v3.* state.uy +beta_y*state.uyy)
g=@(location,state) my_g(location, state,alpha_absorb,beta_absorb,v3);
applyBoundaryCondition(model, ‘neumann’, ‘Edge’, topEdgeID, "q",0,…
‘g’, g);
end
function absorb=my_g(location, state,alpha_absorb,beta_absorb,v3)
n1=1;
nr=numel(location.x);
absorb=zeros(n1,nr);
absorb(1,:)=(-alpha_absorb *v3.* state.uy +beta_absorb*state.uyy);
end
For the method shown, solvepde throws the following error ( and the commented out anonymous functio method throws a similar error)
Unrecognized field name "uy".
Error in MembraneWaveExplorer>my_g (line 303)
absorb(1,:)=(-alpha_absorb *v3.* state.uy +beta_absorb*state.uyy);
Error in MembraneWaveExplorer>@(location,state)my_g(location,state,alpha_absorb,beta_absorb,v3) (line 295)
g=@(location,state) my_g(location, state,alpha_absorb,beta_absorb,v3)
Error in pde.internal.pde3DBCImpl/callNeumannFuncOnFace (line 58)
bci = func(appRegion, state);
Error in pde.internal.pde3DBCImpl/setNeumannBCOnFace (line 133)
faceG = self.callNeumannFuncOnFace(bci,xyzAllFaceNodes, sPts, bci.g, …
Error in pde.internal.pde3DBCImpl/getBCMatrices (line 66)
[Qi, Gi] = setNeumannBCOnFace(self, bcsi);
Error in pde.internal.FESolverUtilities/assembleBoundary (line 74)
bcmat = bcImpl.getBCMatrices(u,time,gmat);
Error in pde.internal.FESolverUtilities/assembleSelectedFEMatrices (line 30)
bmat = self.assembleBoundary(u,time,gmatrix);
Error in pde.DiscretizedPDEModel/initialDiscretization (line 50)
femat0 = self.thePde.assembleSelectedFEMatrices(self.p, self.t, self.coefstruct, u0, tdummy, requiredMats, false);
Error in pde.DiscretizedPDEModel (line 33)
obj = obj.initialDiscretization(u0,tdummy);
Error in pde.DynamicDiscretizedPDEModel (line 32)
obj=obj@pde.DiscretizedPDEModel(thePde,p,e,t,coefstruct,u0,false);
Error in pde.internal.FESolverUtilities/solveTimeDependent (line 27)
femodel=pde.DynamicDiscretizedPDEModel(self,p,e,t,coefstruct,u0,tlist,tsecondOrder);
Error in pde.PDEModel/solvepde (line 57)
[u,dudt] = self.solveTimeDependent(coefstruct, u0, ut0, tlist, …I would appreciate any advice of the following. I am working with PDE Tool box solvepde and a 2d membrane simulation and struggling to impose a spatial-derivative-dependent absorbing a boundary condition on an edge. I am following PDE Toolbox documentation trying two different methods, one (commented out) below using a simple anonymous function and another using a matlab function. These methods work with variables like location.x, location.y, and state.time but seem to fail me with the spatial derivatives. Here is the code snippet in the setup preamble to calling solvepde:
case 3
alpha_absorb=1;beta_absorb=0.0;
m3=m_func(0,ribbonlength/2);
c3=c_func(0,ribbonlength/2);
v3=sqrt(c3(3)/m3);
% my_g= @(location, state,alpha,beta) (-alpha_y *v3.* state.uy +beta_y*state.uyy);
%
% g=@(location,state)(-alpha_y *v3.* state.uy +beta_y*state.uyy)
g=@(location,state) my_g(location, state,alpha_absorb,beta_absorb,v3);
applyBoundaryCondition(model, ‘neumann’, ‘Edge’, topEdgeID, "q",0,…
‘g’, g);
end
function absorb=my_g(location, state,alpha_absorb,beta_absorb,v3)
n1=1;
nr=numel(location.x);
absorb=zeros(n1,nr);
absorb(1,:)=(-alpha_absorb *v3.* state.uy +beta_absorb*state.uyy);
end
For the method shown, solvepde throws the following error ( and the commented out anonymous functio method throws a similar error)
Unrecognized field name "uy".
Error in MembraneWaveExplorer>my_g (line 303)
absorb(1,:)=(-alpha_absorb *v3.* state.uy +beta_absorb*state.uyy);
Error in MembraneWaveExplorer>@(location,state)my_g(location,state,alpha_absorb,beta_absorb,v3) (line 295)
g=@(location,state) my_g(location, state,alpha_absorb,beta_absorb,v3)
Error in pde.internal.pde3DBCImpl/callNeumannFuncOnFace (line 58)
bci = func(appRegion, state);
Error in pde.internal.pde3DBCImpl/setNeumannBCOnFace (line 133)
faceG = self.callNeumannFuncOnFace(bci,xyzAllFaceNodes, sPts, bci.g, …
Error in pde.internal.pde3DBCImpl/getBCMatrices (line 66)
[Qi, Gi] = setNeumannBCOnFace(self, bcsi);
Error in pde.internal.FESolverUtilities/assembleBoundary (line 74)
bcmat = bcImpl.getBCMatrices(u,time,gmat);
Error in pde.internal.FESolverUtilities/assembleSelectedFEMatrices (line 30)
bmat = self.assembleBoundary(u,time,gmatrix);
Error in pde.DiscretizedPDEModel/initialDiscretization (line 50)
femat0 = self.thePde.assembleSelectedFEMatrices(self.p, self.t, self.coefstruct, u0, tdummy, requiredMats, false);
Error in pde.DiscretizedPDEModel (line 33)
obj = obj.initialDiscretization(u0,tdummy);
Error in pde.DynamicDiscretizedPDEModel (line 32)
obj=obj@pde.DiscretizedPDEModel(thePde,p,e,t,coefstruct,u0,false);
Error in pde.internal.FESolverUtilities/solveTimeDependent (line 27)
femodel=pde.DynamicDiscretizedPDEModel(self,p,e,t,coefstruct,u0,tlist,tsecondOrder);
Error in pde.PDEModel/solvepde (line 57)
[u,dudt] = self.solveTimeDependent(coefstruct, u0, ut0, tlist, … I would appreciate any advice of the following. I am working with PDE Tool box solvepde and a 2d membrane simulation and struggling to impose a spatial-derivative-dependent absorbing a boundary condition on an edge. I am following PDE Toolbox documentation trying two different methods, one (commented out) below using a simple anonymous function and another using a matlab function. These methods work with variables like location.x, location.y, and state.time but seem to fail me with the spatial derivatives. Here is the code snippet in the setup preamble to calling solvepde:
case 3
alpha_absorb=1;beta_absorb=0.0;
m3=m_func(0,ribbonlength/2);
c3=c_func(0,ribbonlength/2);
v3=sqrt(c3(3)/m3);
% my_g= @(location, state,alpha,beta) (-alpha_y *v3.* state.uy +beta_y*state.uyy);
%
% g=@(location,state)(-alpha_y *v3.* state.uy +beta_y*state.uyy)
g=@(location,state) my_g(location, state,alpha_absorb,beta_absorb,v3);
applyBoundaryCondition(model, ‘neumann’, ‘Edge’, topEdgeID, "q",0,…
‘g’, g);
end
function absorb=my_g(location, state,alpha_absorb,beta_absorb,v3)
n1=1;
nr=numel(location.x);
absorb=zeros(n1,nr);
absorb(1,:)=(-alpha_absorb *v3.* state.uy +beta_absorb*state.uyy);
end
For the method shown, solvepde throws the following error ( and the commented out anonymous functio method throws a similar error)
Unrecognized field name "uy".
Error in MembraneWaveExplorer>my_g (line 303)
absorb(1,:)=(-alpha_absorb *v3.* state.uy +beta_absorb*state.uyy);
Error in MembraneWaveExplorer>@(location,state)my_g(location,state,alpha_absorb,beta_absorb,v3) (line 295)
g=@(location,state) my_g(location, state,alpha_absorb,beta_absorb,v3)
Error in pde.internal.pde3DBCImpl/callNeumannFuncOnFace (line 58)
bci = func(appRegion, state);
Error in pde.internal.pde3DBCImpl/setNeumannBCOnFace (line 133)
faceG = self.callNeumannFuncOnFace(bci,xyzAllFaceNodes, sPts, bci.g, …
Error in pde.internal.pde3DBCImpl/getBCMatrices (line 66)
[Qi, Gi] = setNeumannBCOnFace(self, bcsi);
Error in pde.internal.FESolverUtilities/assembleBoundary (line 74)
bcmat = bcImpl.getBCMatrices(u,time,gmat);
Error in pde.internal.FESolverUtilities/assembleSelectedFEMatrices (line 30)
bmat = self.assembleBoundary(u,time,gmatrix);
Error in pde.DiscretizedPDEModel/initialDiscretization (line 50)
femat0 = self.thePde.assembleSelectedFEMatrices(self.p, self.t, self.coefstruct, u0, tdummy, requiredMats, false);
Error in pde.DiscretizedPDEModel (line 33)
obj = obj.initialDiscretization(u0,tdummy);
Error in pde.DynamicDiscretizedPDEModel (line 32)
obj=obj@pde.DiscretizedPDEModel(thePde,p,e,t,coefstruct,u0,false);
Error in pde.internal.FESolverUtilities/solveTimeDependent (line 27)
femodel=pde.DynamicDiscretizedPDEModel(self,p,e,t,coefstruct,u0,tlist,tsecondOrder);
Error in pde.PDEModel/solvepde (line 57)
[u,dudt] = self.solveTimeDependent(coefstruct, u0, ut0, tlist, … pdesolve, edge boundary condition MATLAB Answers — New Questions
RL DDPG agent does not seem to learn, aircraft control problem
Hello everyone,
I’m back with some updates on my mixed Reinforcement Learning (RL) and Supervised Learning training. A few days ago, I posted a question here on MathWorks about the working principle of “external actions” in the RL training block. Based on the suggestions I received, I have started a hybrid training approach.
I begin by injecting external actions from the controller for 75 seconds (1/4 of the entire episode length). After this, the agent takes action until the pitch rate error reaches 5 degrees per second. When this threshold is reached, the external agent takes control again. The external actions are then cut off when the pitch rate is very close to 0 degrees per second for about 40 seconds. The agent then takes control again, and this cycle continues.
I have also introduced a maximum number of allowed interventions. If the agent exceeds this threshold, the simulation stops and a penalty is applied. I also apply a penalty every time the external controller must intervene again, while a bonus is given every time the agent makes progress within the time window when it is left alone. This system of bonuses and penalties is added to the standard reward, which takes into account the altitude error, the flight path angle error, and the pitch rate error. The weight coefficients for these errors are 1, 1, and 10, respectively, because I want to emphasize that the aircraft must maintain level wings.
The initial conditions are always random, and the setpoint for altitude is always set 50 meters above the initial altitude.
Unfortunately, after the first training session, I haven’t seen any progress. According to your opinion, is it worth taking another attempt or is the whole setup wrong? Thank you.Hello everyone,
I’m back with some updates on my mixed Reinforcement Learning (RL) and Supervised Learning training. A few days ago, I posted a question here on MathWorks about the working principle of “external actions” in the RL training block. Based on the suggestions I received, I have started a hybrid training approach.
I begin by injecting external actions from the controller for 75 seconds (1/4 of the entire episode length). After this, the agent takes action until the pitch rate error reaches 5 degrees per second. When this threshold is reached, the external agent takes control again. The external actions are then cut off when the pitch rate is very close to 0 degrees per second for about 40 seconds. The agent then takes control again, and this cycle continues.
I have also introduced a maximum number of allowed interventions. If the agent exceeds this threshold, the simulation stops and a penalty is applied. I also apply a penalty every time the external controller must intervene again, while a bonus is given every time the agent makes progress within the time window when it is left alone. This system of bonuses and penalties is added to the standard reward, which takes into account the altitude error, the flight path angle error, and the pitch rate error. The weight coefficients for these errors are 1, 1, and 10, respectively, because I want to emphasize that the aircraft must maintain level wings.
The initial conditions are always random, and the setpoint for altitude is always set 50 meters above the initial altitude.
Unfortunately, after the first training session, I haven’t seen any progress. According to your opinion, is it worth taking another attempt or is the whole setup wrong? Thank you. Hello everyone,
I’m back with some updates on my mixed Reinforcement Learning (RL) and Supervised Learning training. A few days ago, I posted a question here on MathWorks about the working principle of “external actions” in the RL training block. Based on the suggestions I received, I have started a hybrid training approach.
I begin by injecting external actions from the controller for 75 seconds (1/4 of the entire episode length). After this, the agent takes action until the pitch rate error reaches 5 degrees per second. When this threshold is reached, the external agent takes control again. The external actions are then cut off when the pitch rate is very close to 0 degrees per second for about 40 seconds. The agent then takes control again, and this cycle continues.
I have also introduced a maximum number of allowed interventions. If the agent exceeds this threshold, the simulation stops and a penalty is applied. I also apply a penalty every time the external controller must intervene again, while a bonus is given every time the agent makes progress within the time window when it is left alone. This system of bonuses and penalties is added to the standard reward, which takes into account the altitude error, the flight path angle error, and the pitch rate error. The weight coefficients for these errors are 1, 1, and 10, respectively, because I want to emphasize that the aircraft must maintain level wings.
The initial conditions are always random, and the setpoint for altitude is always set 50 meters above the initial altitude.
Unfortunately, after the first training session, I haven’t seen any progress. According to your opinion, is it worth taking another attempt or is the whole setup wrong? Thank you. rl, reinforcement learning, machine learning, ddpg, control theory, aircraft MATLAB Answers — New Questions
F-Test Fixed Effects SSRs – reduced model smaller than complete model
Hello! I’m trying to make a modelwide (not individual coefficient specific, like with anova) f-test for my fixed-effects regressions – I can’t seem to find a native function in matlab for them so I’m just building them, but if you’ve got one send it my way. My plan was to do something like the following:
fe_green_money = fitlme(fixed_effects_green_data, ‘LogPatents ~ MoneyInvested + Dummy0Patents + (1|Organization)’)
fe_green_money_reduced = fitlme(fixed_effects_green_data, ‘LogPatents ~ 1 + (1|Organization)’)
F_fe_green_money = ((fe_green_money_reduced.SSR – fe_green_money.SSR) / 2) / (fe_green_money.SSR / fe_green_money.DFE);
p_fe_green_money = 1 – fcdf(F_fe_green_money, 2, fe_green_money.DFE)
But I’m running into a problem – fe_green_money_reduced.SSR is smaller (almost 2/3rds the size) than fe_green_money.SSR, which as I understand it should be impossible… Is there an alternate way I should be getting the SSRs or am I doing something wrong or is there another explanation I’m missing?Hello! I’m trying to make a modelwide (not individual coefficient specific, like with anova) f-test for my fixed-effects regressions – I can’t seem to find a native function in matlab for them so I’m just building them, but if you’ve got one send it my way. My plan was to do something like the following:
fe_green_money = fitlme(fixed_effects_green_data, ‘LogPatents ~ MoneyInvested + Dummy0Patents + (1|Organization)’)
fe_green_money_reduced = fitlme(fixed_effects_green_data, ‘LogPatents ~ 1 + (1|Organization)’)
F_fe_green_money = ((fe_green_money_reduced.SSR – fe_green_money.SSR) / 2) / (fe_green_money.SSR / fe_green_money.DFE);
p_fe_green_money = 1 – fcdf(F_fe_green_money, 2, fe_green_money.DFE)
But I’m running into a problem – fe_green_money_reduced.SSR is smaller (almost 2/3rds the size) than fe_green_money.SSR, which as I understand it should be impossible… Is there an alternate way I should be getting the SSRs or am I doing something wrong or is there another explanation I’m missing? Hello! I’m trying to make a modelwide (not individual coefficient specific, like with anova) f-test for my fixed-effects regressions – I can’t seem to find a native function in matlab for them so I’m just building them, but if you’ve got one send it my way. My plan was to do something like the following:
fe_green_money = fitlme(fixed_effects_green_data, ‘LogPatents ~ MoneyInvested + Dummy0Patents + (1|Organization)’)
fe_green_money_reduced = fitlme(fixed_effects_green_data, ‘LogPatents ~ 1 + (1|Organization)’)
F_fe_green_money = ((fe_green_money_reduced.SSR – fe_green_money.SSR) / 2) / (fe_green_money.SSR / fe_green_money.DFE);
p_fe_green_money = 1 – fcdf(F_fe_green_money, 2, fe_green_money.DFE)
But I’m running into a problem – fe_green_money_reduced.SSR is smaller (almost 2/3rds the size) than fe_green_money.SSR, which as I understand it should be impossible… Is there an alternate way I should be getting the SSRs or am I doing something wrong or is there another explanation I’m missing? fixed effects, matlab, f-test, sum of squared residuals MATLAB Answers — New Questions
Why I have a PV voltage at zero irradiance ? Why I don’t have current reading ?
Hello there,
I am trying to simulate the performance of a PV system and I have the site irradiance and assume a constant temperature. However, the voltage readings are not looks right. The voltage rise rate doesn’t look right and I even have a voltage at zero irradiance and I have zero current reading as shown in the attachments. When I connected a current source to drain current, results become more unlogic to me.Hello there,
I am trying to simulate the performance of a PV system and I have the site irradiance and assume a constant temperature. However, the voltage readings are not looks right. The voltage rise rate doesn’t look right and I even have a voltage at zero irradiance and I have zero current reading as shown in the attachments. When I connected a current source to drain current, results become more unlogic to me. Hello there,
I am trying to simulate the performance of a PV system and I have the site irradiance and assume a constant temperature. However, the voltage readings are not looks right. The voltage rise rate doesn’t look right and I even have a voltage at zero irradiance and I have zero current reading as shown in the attachments. When I connected a current source to drain current, results become more unlogic to me. simulink, pv MATLAB Answers — New Questions
How to build an empiric cdf/pdf of a compound poisson continuos distribution
Hi everyone.
as I said in the title i’m trying to obtain the empiric cdf (or pdf) of a compound poisson continuos distribution. Let be a compound poisson distribution with as parameters, while being the parameter of the random variable N (poisson) and F being the distribution of the i-th Y (assuming all are iid and extracted from the same lognormal distribution of given parameters). I managed to build a vector called "x_ptf" which contains random values extracted from , however im struggling into obtaining the empirical cdf/pdf.
clear all; close all; clc
rng(200724)
%mean and standard deviation of a given sample (sample of Yi)
mu_c = 4432.62; var_c= 533130.21;
%lognormal parameters
var_log = log(var_c/mu_c^2+1); sig_log = sqrt(var_log);
mu_log = -var_log/2 +log(mu_c);
%Compound-Poisson distribution
lam = 570; %poisson distribution parameter
nsims = 10^5; %number of simulations
num = poissrnd(lam,1,nsims); %random numbers extracted from the N poisson variable
x_ptf = zeros(nsims,1); %iniziatiling the storage where the random generated numbers will be allocated
for i = 1:length(num)
x_ptf(i) = sum(lognrnd(mu_log,sig_log,1,num(i))); %building randomly generated numbers
end
[cdf, X_ptf] = ecdf(x_con);
X_con = X_con(2:end); cdf = cdf(2:end); %doing this because i get zero two times as the first two components of X_con vector
p = [cdf(1) diff(cdf)’]’; %building the pdf from the cdf
E = sum(X_con.*p); %empirical mean
plot(X_con,p,’*’); %this plot doesn’t make sense
The empirical mean is correct, but the pdf distribution is wrong as shown by the plot. I think it means there’s some problem with the "ecfd" function im using, is there any way to fix? Or maybe some other functions i could try? Ive already used "ksdensity" but it’s not working. Can somebody help?Hi everyone.
as I said in the title i’m trying to obtain the empiric cdf (or pdf) of a compound poisson continuos distribution. Let be a compound poisson distribution with as parameters, while being the parameter of the random variable N (poisson) and F being the distribution of the i-th Y (assuming all are iid and extracted from the same lognormal distribution of given parameters). I managed to build a vector called "x_ptf" which contains random values extracted from , however im struggling into obtaining the empirical cdf/pdf.
clear all; close all; clc
rng(200724)
%mean and standard deviation of a given sample (sample of Yi)
mu_c = 4432.62; var_c= 533130.21;
%lognormal parameters
var_log = log(var_c/mu_c^2+1); sig_log = sqrt(var_log);
mu_log = -var_log/2 +log(mu_c);
%Compound-Poisson distribution
lam = 570; %poisson distribution parameter
nsims = 10^5; %number of simulations
num = poissrnd(lam,1,nsims); %random numbers extracted from the N poisson variable
x_ptf = zeros(nsims,1); %iniziatiling the storage where the random generated numbers will be allocated
for i = 1:length(num)
x_ptf(i) = sum(lognrnd(mu_log,sig_log,1,num(i))); %building randomly generated numbers
end
[cdf, X_ptf] = ecdf(x_con);
X_con = X_con(2:end); cdf = cdf(2:end); %doing this because i get zero two times as the first two components of X_con vector
p = [cdf(1) diff(cdf)’]’; %building the pdf from the cdf
E = sum(X_con.*p); %empirical mean
plot(X_con,p,’*’); %this plot doesn’t make sense
The empirical mean is correct, but the pdf distribution is wrong as shown by the plot. I think it means there’s some problem with the "ecfd" function im using, is there any way to fix? Or maybe some other functions i could try? Ive already used "ksdensity" but it’s not working. Can somebody help? Hi everyone.
as I said in the title i’m trying to obtain the empiric cdf (or pdf) of a compound poisson continuos distribution. Let be a compound poisson distribution with as parameters, while being the parameter of the random variable N (poisson) and F being the distribution of the i-th Y (assuming all are iid and extracted from the same lognormal distribution of given parameters). I managed to build a vector called "x_ptf" which contains random values extracted from , however im struggling into obtaining the empirical cdf/pdf.
clear all; close all; clc
rng(200724)
%mean and standard deviation of a given sample (sample of Yi)
mu_c = 4432.62; var_c= 533130.21;
%lognormal parameters
var_log = log(var_c/mu_c^2+1); sig_log = sqrt(var_log);
mu_log = -var_log/2 +log(mu_c);
%Compound-Poisson distribution
lam = 570; %poisson distribution parameter
nsims = 10^5; %number of simulations
num = poissrnd(lam,1,nsims); %random numbers extracted from the N poisson variable
x_ptf = zeros(nsims,1); %iniziatiling the storage where the random generated numbers will be allocated
for i = 1:length(num)
x_ptf(i) = sum(lognrnd(mu_log,sig_log,1,num(i))); %building randomly generated numbers
end
[cdf, X_ptf] = ecdf(x_con);
X_con = X_con(2:end); cdf = cdf(2:end); %doing this because i get zero two times as the first two components of X_con vector
p = [cdf(1) diff(cdf)’]’; %building the pdf from the cdf
E = sum(X_con.*p); %empirical mean
plot(X_con,p,’*’); %this plot doesn’t make sense
The empirical mean is correct, but the pdf distribution is wrong as shown by the plot. I think it means there’s some problem with the "ecfd" function im using, is there any way to fix? Or maybe some other functions i could try? Ive already used "ksdensity" but it’s not working. Can somebody help? matlab, montecarlo, random number generator, empirical cdf, statistics MATLAB Answers — New Questions
How to drive a prismatic joint by setting the input to “motion / provided by input”
I would like to set the input of the prismatic joint to "motion / provided by input" and raise it by 0.5 meters. As far as I know, a prismatic joint can be driven to a target position if it has inputs for position, velocity, and acceleration. However, I do not know the method to input these values. If anyone knows, could you please provide an example of the input method? Thank you.I would like to set the input of the prismatic joint to "motion / provided by input" and raise it by 0.5 meters. As far as I know, a prismatic joint can be driven to a target position if it has inputs for position, velocity, and acceleration. However, I do not know the method to input these values. If anyone knows, could you please provide an example of the input method? Thank you. I would like to set the input of the prismatic joint to "motion / provided by input" and raise it by 0.5 meters. As far as I know, a prismatic joint can be driven to a target position if it has inputs for position, velocity, and acceleration. However, I do not know the method to input these values. If anyone knows, could you please provide an example of the input method? Thank you. simulink, simscape MATLAB Answers — New Questions
How can I plot a bar chart with 4 different y-axis and standard deviation?
Hello,
I would like to have a bar plot with 4 different categories. Each has got its own y-axis, as shown in the attached picture.
<</matlabcentral/answers/uploaded_files/79925/bar_4y-axis.JPG>>
I figured out that there is a possibility to add mutlitple axis to a plot <https://de.mathworks.com/matlabcentral/fileexchange/9016-addaxis (addaxis)>. I’m using MATLAB R2014a, but I have access to R2017a at my university, if needed.
This is my current code, based on this <https://de.mathworks.com/matlabcentral/answers/136433-how-to-add-errorbars example>:
function[]=test_multiple_axis_2()
w=[1.0,2.5,3.9,9.8,5.5,6.6,8.8,5.4,7.4,6.5];
x=[11.1,21.5,23.7,19.8,14.7,15.6,12.7,13.8,14.9,11.4];
y=[15.7,16.8,25.9,18.6,16.9,20.4,23.8,19.9,17.8,21.8];
z=[21.5,26.8,17.7,18.9,16.5,25.6,29.3,18.9,26.8,24.5];
std_w=[0.7,1.7,1.7,4.5,0.1,4.8,1.2,4.1,1.4,1.0];
std_x=[2.2,5.4,3.3,5.2,1.9,4.8,5.4,3.2,4.7,6.2];
std_y=[6.2,2.5,2.6,3.9,7.8,4.1,5.6,4.2,6.6,7.1];
std_z=[8.7,5.4,6.5,7.4,2.3,2.2,1.9,9.2,1.7,7.5];
hb = bar([1 2 3 4 5 6 7 8 9 10],[w’ x’ y’ z’])
legend(‘w’,’x’,’y’,’z’);
set(gca, ‘FontSize’,12,’XTick’,[1 2 3 4 5 6 7 8 9 10],’XTickLabel’,{‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’});
ylabel(‘unit w’)%Here should be the addaxis code
errbar = [std_w; std_x; std_y; std_z]; % CREATE ‘errbar’ MATRIX
yd = [w’ x’ y’ z’]’;
keyboard %i didn’t understand the following code
hold on
for k1 = 1:3
errorbar([1:3]+.22*(k1-2), yd(k1,:), errbar(k1,:), ‘.k’, ‘LineWidth’,2)
end
hold off
returnHello,
I would like to have a bar plot with 4 different categories. Each has got its own y-axis, as shown in the attached picture.
<</matlabcentral/answers/uploaded_files/79925/bar_4y-axis.JPG>>
I figured out that there is a possibility to add mutlitple axis to a plot <https://de.mathworks.com/matlabcentral/fileexchange/9016-addaxis (addaxis)>. I’m using MATLAB R2014a, but I have access to R2017a at my university, if needed.
This is my current code, based on this <https://de.mathworks.com/matlabcentral/answers/136433-how-to-add-errorbars example>:
function[]=test_multiple_axis_2()
w=[1.0,2.5,3.9,9.8,5.5,6.6,8.8,5.4,7.4,6.5];
x=[11.1,21.5,23.7,19.8,14.7,15.6,12.7,13.8,14.9,11.4];
y=[15.7,16.8,25.9,18.6,16.9,20.4,23.8,19.9,17.8,21.8];
z=[21.5,26.8,17.7,18.9,16.5,25.6,29.3,18.9,26.8,24.5];
std_w=[0.7,1.7,1.7,4.5,0.1,4.8,1.2,4.1,1.4,1.0];
std_x=[2.2,5.4,3.3,5.2,1.9,4.8,5.4,3.2,4.7,6.2];
std_y=[6.2,2.5,2.6,3.9,7.8,4.1,5.6,4.2,6.6,7.1];
std_z=[8.7,5.4,6.5,7.4,2.3,2.2,1.9,9.2,1.7,7.5];
hb = bar([1 2 3 4 5 6 7 8 9 10],[w’ x’ y’ z’])
legend(‘w’,’x’,’y’,’z’);
set(gca, ‘FontSize’,12,’XTick’,[1 2 3 4 5 6 7 8 9 10],’XTickLabel’,{‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’});
ylabel(‘unit w’)%Here should be the addaxis code
errbar = [std_w; std_x; std_y; std_z]; % CREATE ‘errbar’ MATRIX
yd = [w’ x’ y’ z’]’;
keyboard %i didn’t understand the following code
hold on
for k1 = 1:3
errorbar([1:3]+.22*(k1-2), yd(k1,:), errbar(k1,:), ‘.k’, ‘LineWidth’,2)
end
hold off
return Hello,
I would like to have a bar plot with 4 different categories. Each has got its own y-axis, as shown in the attached picture.
<</matlabcentral/answers/uploaded_files/79925/bar_4y-axis.JPG>>
I figured out that there is a possibility to add mutlitple axis to a plot <https://de.mathworks.com/matlabcentral/fileexchange/9016-addaxis (addaxis)>. I’m using MATLAB R2014a, but I have access to R2017a at my university, if needed.
This is my current code, based on this <https://de.mathworks.com/matlabcentral/answers/136433-how-to-add-errorbars example>:
function[]=test_multiple_axis_2()
w=[1.0,2.5,3.9,9.8,5.5,6.6,8.8,5.4,7.4,6.5];
x=[11.1,21.5,23.7,19.8,14.7,15.6,12.7,13.8,14.9,11.4];
y=[15.7,16.8,25.9,18.6,16.9,20.4,23.8,19.9,17.8,21.8];
z=[21.5,26.8,17.7,18.9,16.5,25.6,29.3,18.9,26.8,24.5];
std_w=[0.7,1.7,1.7,4.5,0.1,4.8,1.2,4.1,1.4,1.0];
std_x=[2.2,5.4,3.3,5.2,1.9,4.8,5.4,3.2,4.7,6.2];
std_y=[6.2,2.5,2.6,3.9,7.8,4.1,5.6,4.2,6.6,7.1];
std_z=[8.7,5.4,6.5,7.4,2.3,2.2,1.9,9.2,1.7,7.5];
hb = bar([1 2 3 4 5 6 7 8 9 10],[w’ x’ y’ z’])
legend(‘w’,’x’,’y’,’z’);
set(gca, ‘FontSize’,12,’XTick’,[1 2 3 4 5 6 7 8 9 10],’XTickLabel’,{‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’});
ylabel(‘unit w’)%Here should be the addaxis code
errbar = [std_w; std_x; std_y; std_z]; % CREATE ‘errbar’ MATRIX
yd = [w’ x’ y’ z’]’;
keyboard %i didn’t understand the following code
hold on
for k1 = 1:3
errorbar([1:3]+.22*(k1-2), yd(k1,:), errbar(k1,:), ‘.k’, ‘LineWidth’,2)
end
hold off
return bar plot, standard deviation, multiple axis MATLAB Answers — New Questions
plot an obtained function after several calculus
Good morning!
I want to plot the folloing function which is obtained after several calculus on Matlab,
syms s t a
Y=(sin(int(cos((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/9))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/18)))^2/100)^2*(exp(-2*s^(1/3)) + cos(int(sin(0.00008414709848078965066525023216303*cos(a)^2 + 0.008414709848078965066525023216303*exp(-2*a^(1/2))) + 1, a, 0, s^(2/3)))^2/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/6)))^2/100)^2)^2, s, 0, 1))/100 + sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/18))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/36)))^2/100)*(exp(-2*t^(1/6)) + cos(int(sin(0.00008414709848078965066525023216303*cos(s)^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/2))) + 1, s, 0, t^(1/3)))^2/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/12)))^2/100))^2/100)*(exp(-2*t) + cos(int(sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/12)))^2/100)*(exp(-2*s^(1/2)) + sin(0.00008414709848078965066525023216303*cos(s^(1/2))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/4)))^2/100 + cos(int(sin(0.00008414709848078965066525023216303*cos(a)^2 + 0.008414709848078965066525023216303*exp(-2*a^(1/2))) + 1, a, 0, s))^2/100)) + 1, s, 0, t^2))^2/100 + sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/12)))^2/100)*(exp(-2*t^(1/2)) + cos(int(sin(0.00008414709848078965066525023216303*cos(s)^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/2))) + 1, s, 0, t))^2/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/2))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/4)))^2/100))^2/100)
in this function another variable appeared (denoted by ‘ a’ ) so i add it in symbolique variable
To plot this function i used the folowing code:
t_vals=linspace(0, 1, 10);
figure(1)
hold on
y_eval = double(eval(subs(Y(i+1),t, t_vals)))
plot(t_vals, y_eval;
hold offGood morning!
I want to plot the folloing function which is obtained after several calculus on Matlab,
syms s t a
Y=(sin(int(cos((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/9))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/18)))^2/100)^2*(exp(-2*s^(1/3)) + cos(int(sin(0.00008414709848078965066525023216303*cos(a)^2 + 0.008414709848078965066525023216303*exp(-2*a^(1/2))) + 1, a, 0, s^(2/3)))^2/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/6)))^2/100)^2)^2, s, 0, 1))/100 + sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/18))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/36)))^2/100)*(exp(-2*t^(1/6)) + cos(int(sin(0.00008414709848078965066525023216303*cos(s)^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/2))) + 1, s, 0, t^(1/3)))^2/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/12)))^2/100))^2/100)*(exp(-2*t) + cos(int(sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/12)))^2/100)*(exp(-2*s^(1/2)) + sin(0.00008414709848078965066525023216303*cos(s^(1/2))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/4)))^2/100 + cos(int(sin(0.00008414709848078965066525023216303*cos(a)^2 + 0.008414709848078965066525023216303*exp(-2*a^(1/2))) + 1, a, 0, s))^2/100)) + 1, s, 0, t^2))^2/100 + sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/12)))^2/100)*(exp(-2*t^(1/2)) + cos(int(sin(0.00008414709848078965066525023216303*cos(s)^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/2))) + 1, s, 0, t))^2/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/2))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/4)))^2/100))^2/100)
in this function another variable appeared (denoted by ‘ a’ ) so i add it in symbolique variable
To plot this function i used the folowing code:
t_vals=linspace(0, 1, 10);
figure(1)
hold on
y_eval = double(eval(subs(Y(i+1),t, t_vals)))
plot(t_vals, y_eval;
hold off Good morning!
I want to plot the folloing function which is obtained after several calculus on Matlab,
syms s t a
Y=(sin(int(cos((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/9))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/18)))^2/100)^2*(exp(-2*s^(1/3)) + cos(int(sin(0.00008414709848078965066525023216303*cos(a)^2 + 0.008414709848078965066525023216303*exp(-2*a^(1/2))) + 1, a, 0, s^(2/3)))^2/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/6)))^2/100)^2)^2, s, 0, 1))/100 + sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/18))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/36)))^2/100)*(exp(-2*t^(1/6)) + cos(int(sin(0.00008414709848078965066525023216303*cos(s)^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/2))) + 1, s, 0, t^(1/3)))^2/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/12)))^2/100))^2/100)*(exp(-2*t) + cos(int(sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(s^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/12)))^2/100)*(exp(-2*s^(1/2)) + sin(0.00008414709848078965066525023216303*cos(s^(1/2))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/4)))^2/100 + cos(int(sin(0.00008414709848078965066525023216303*cos(a)^2 + 0.008414709848078965066525023216303*exp(-2*a^(1/2))) + 1, a, 0, s))^2/100)) + 1, s, 0, t^2))^2/100 + sin((sin(int(cos((0.00008414709848078965066525023216303*cos(s^(2/3))^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/3)))^2)^2, s, 0, 1))/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/6))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/12)))^2/100)*(exp(-2*t^(1/2)) + cos(int(sin(0.00008414709848078965066525023216303*cos(s)^2 + 0.008414709848078965066525023216303*exp(-2*s^(1/2))) + 1, s, 0, t))^2/100 + sin(0.00008414709848078965066525023216303*cos(t^(1/2))^2 + 0.008414709848078965066525023216303*exp(-2*t^(1/4)))^2/100))^2/100)
in this function another variable appeared (denoted by ‘ a’ ) so i add it in symbolique variable
To plot this function i used the folowing code:
t_vals=linspace(0, 1, 10);
figure(1)
hold on
y_eval = double(eval(subs(Y(i+1),t, t_vals)))
plot(t_vals, y_eval;
hold off plot, symbolique function MATLAB Answers — New Questions
plot several equation and extract vertices
How can I plot in the same graph this 4 linear equations ?
y = 1
y = -4x + 1
x=4
2x+5y = 23
It’s possible to extract algebraically vertexes of the quadrilateral picture?How can I plot in the same graph this 4 linear equations ?
y = 1
y = -4x + 1
x=4
2x+5y = 23
It’s possible to extract algebraically vertexes of the quadrilateral picture? How can I plot in the same graph this 4 linear equations ?
y = 1
y = -4x + 1
x=4
2x+5y = 23
It’s possible to extract algebraically vertexes of the quadrilateral picture? plot, vertex, equation MATLAB Answers — New Questions
Derivative of state ‘1’ in block ‘model4/PMSM /Integrator’ at time 1.09996 is not finite
Could you please help me to solve the following error.
I am triing to find integrl squer error for pi controller and get this error
Error using fun (line 16) Derivative of state ‘1’ in block ‘model4/PMSM /Integrator’ at time 1.09996 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)Could you please help me to solve the following error.
I am triing to find integrl squer error for pi controller and get this error
Error using fun (line 16) Derivative of state ‘1’ in block ‘model4/PMSM /Integrator’ at time 1.09996 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances) Could you please help me to solve the following error.
I am triing to find integrl squer error for pi controller and get this error
Error using fun (line 16) Derivative of state ‘1’ in block ‘model4/PMSM /Integrator’ at time 1.09996 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances) simulink, power_electronics_control, power_conversion_control, electric_motor_control, control system, pi controllrt MATLAB Answers — New Questions
Variable frequency Square pulse – Simulink
Hi,
I would like to know how can I generate a variable frequency controlled square pulse with 50% duty cycle in Simulink? I wish to vary the frequency in the range of 2KHz to 5.5KHz. It would be nice if you guys could help me.
Thanks a ton!Hi,
I would like to know how can I generate a variable frequency controlled square pulse with 50% duty cycle in Simulink? I wish to vary the frequency in the range of 2KHz to 5.5KHz. It would be nice if you guys could help me.
Thanks a ton! Hi,
I would like to know how can I generate a variable frequency controlled square pulse with 50% duty cycle in Simulink? I wish to vary the frequency in the range of 2KHz to 5.5KHz. It would be nice if you guys could help me.
Thanks a ton! simulink, pulse generator, variable frequency MATLAB Answers — New Questions
Add SINGLE element to array or vector
I have a vector of the format:
x = [xval(1) xval(2) … xval(n)]
, and I want to add an element to the end, xval(n+1). How do I do that?I have a vector of the format:
x = [xval(1) xval(2) … xval(n)]
, and I want to add an element to the end, xval(n+1). How do I do that? I have a vector of the format:
x = [xval(1) xval(2) … xval(n)]
, and I want to add an element to the end, xval(n+1). How do I do that? append valur to vector, deep learning MATLAB Answers — New Questions
how to remove noise from audio using fourier transform and filter and to obtain back the original audio signal
[y,Fs]=audioread(‘audio.wav’);
%Normal sound
sound(y,Fs);
subplot(3,1,1);
plot(y);
x=y(1:2:length(y));%x=y(1:2:end)
%Decimated sound
sound(x,Fs);
subplot(3,1,2);
plot(x);
xn=randn(384362,1);
yn=y+xn;
sound(yn,Fs);
x1(1)=y(1);
g=length(y)-1;
j=2;
i=2;
while g~=0
m=rem(i,2);
if m==0
x1(i)=0;
else
x1(i)=y(j);
j=j+1;
g=g-1;
end
i=i+1;
end
%Interpolated sound
sound(x1,Fs);
subplot(3,1,3);
plot(x1);
srate = 10000;
time = 0:1/srate:2;
npnts = length(time);
% signal
signal = y;
% Fourier spectrum
signalX = fft(signal);
hz = linspace(0,srate/2,npnts);
% amplitude
ampl = abs(signalX(1:length(hz)));
figure(1);
stem(signal);
figure(2), clf
stem(hz,ampl,’ks-‘,’linew’,3,’markersize’,10,’markerfacecolor’,’w’)
% make plot look a bit nicer
set(gca,’xlim’,[0 10])
xlabel(‘Frequency (Hz)’), ylabel(‘Amplitude (a.u.)’)[y,Fs]=audioread(‘audio.wav’);
%Normal sound
sound(y,Fs);
subplot(3,1,1);
plot(y);
x=y(1:2:length(y));%x=y(1:2:end)
%Decimated sound
sound(x,Fs);
subplot(3,1,2);
plot(x);
xn=randn(384362,1);
yn=y+xn;
sound(yn,Fs);
x1(1)=y(1);
g=length(y)-1;
j=2;
i=2;
while g~=0
m=rem(i,2);
if m==0
x1(i)=0;
else
x1(i)=y(j);
j=j+1;
g=g-1;
end
i=i+1;
end
%Interpolated sound
sound(x1,Fs);
subplot(3,1,3);
plot(x1);
srate = 10000;
time = 0:1/srate:2;
npnts = length(time);
% signal
signal = y;
% Fourier spectrum
signalX = fft(signal);
hz = linspace(0,srate/2,npnts);
% amplitude
ampl = abs(signalX(1:length(hz)));
figure(1);
stem(signal);
figure(2), clf
stem(hz,ampl,’ks-‘,’linew’,3,’markersize’,10,’markerfacecolor’,’w’)
% make plot look a bit nicer
set(gca,’xlim’,[0 10])
xlabel(‘Frequency (Hz)’), ylabel(‘Amplitude (a.u.)’) [y,Fs]=audioread(‘audio.wav’);
%Normal sound
sound(y,Fs);
subplot(3,1,1);
plot(y);
x=y(1:2:length(y));%x=y(1:2:end)
%Decimated sound
sound(x,Fs);
subplot(3,1,2);
plot(x);
xn=randn(384362,1);
yn=y+xn;
sound(yn,Fs);
x1(1)=y(1);
g=length(y)-1;
j=2;
i=2;
while g~=0
m=rem(i,2);
if m==0
x1(i)=0;
else
x1(i)=y(j);
j=j+1;
g=g-1;
end
i=i+1;
end
%Interpolated sound
sound(x1,Fs);
subplot(3,1,3);
plot(x1);
srate = 10000;
time = 0:1/srate:2;
npnts = length(time);
% signal
signal = y;
% Fourier spectrum
signalX = fft(signal);
hz = linspace(0,srate/2,npnts);
% amplitude
ampl = abs(signalX(1:length(hz)));
figure(1);
stem(signal);
figure(2), clf
stem(hz,ampl,’ks-‘,’linew’,3,’markersize’,10,’markerfacecolor’,’w’)
% make plot look a bit nicer
set(gca,’xlim’,[0 10])
xlabel(‘Frequency (Hz)’), ylabel(‘Amplitude (a.u.)’) audio MATLAB Answers — New Questions
Is it possible to implement FOC plant model on Arduino?
I’m trying implement a FOC plant model on Arduino using S32K144 as input pulse generator. I tried looking into some examples but I’m not finding clarity on what blocksets to use.I’m trying implement a FOC plant model on Arduino using S32K144 as input pulse generator. I tried looking into some examples but I’m not finding clarity on what blocksets to use. I’m trying implement a FOC plant model on Arduino using S32K144 as input pulse generator. I tried looking into some examples but I’m not finding clarity on what blocksets to use. power_electronics_control MATLAB Answers — New Questions
Hypervolume computation with PlatEMO
Does anybody know how can i apply this set of code (HV.m) from PlatEMO (https://github.com/BIMK/PlatEMO/blob/1274e2530e1c5afa928f3691c65af7d2f7efe099/PlatEMO/Metrics/HV.m)
I’ve tried to execute it with the population solutions obtained from my algorithm and the optimum values obtained across several benchmark dataset as follows, however the output for hypervolume value that i’ve got is extremely low, what could be the problem?
inputs:
solutions = [43,176,38;43,177,37;42,188,38;46,168,38;43,184,36;42,178,48;42,169,49;42,179,42];
Population.best = struct(‘objs’, []);
% Fill the structure array with the solutions
for i = 1:size(solutions, 1)
Population.best(i).objs = solutions(i, :);
end
optimum = [40, 162, 38 ; 40, 164, 37 ;40, 167, 36; 40,171,36; 40,165,37; 40,169,36 ; 41, 160, 38 ;41, 163, 37 ;42, 157, 40 ;42, 158, 39 ;42, 165, 36 ; 42,162,42 ; 43, 155, 40 ;44, 154, 40 ;45, 153, 42];
hv = HV(Population, optimum);
disp([‘Hypervolume: ‘, num2str(hv)]);
in HV.m:
function score = HV(Population,optimum)
PopObj = vertcat(Population.best.objs);
… and the rest of the code from (https://github.com/BIMK/PlatEMO/blob/1274e2530e1c5afa928f3691c65af7d2f7efe099/PlatEMO/Metrics/HV.m)Does anybody know how can i apply this set of code (HV.m) from PlatEMO (https://github.com/BIMK/PlatEMO/blob/1274e2530e1c5afa928f3691c65af7d2f7efe099/PlatEMO/Metrics/HV.m)
I’ve tried to execute it with the population solutions obtained from my algorithm and the optimum values obtained across several benchmark dataset as follows, however the output for hypervolume value that i’ve got is extremely low, what could be the problem?
inputs:
solutions = [43,176,38;43,177,37;42,188,38;46,168,38;43,184,36;42,178,48;42,169,49;42,179,42];
Population.best = struct(‘objs’, []);
% Fill the structure array with the solutions
for i = 1:size(solutions, 1)
Population.best(i).objs = solutions(i, :);
end
optimum = [40, 162, 38 ; 40, 164, 37 ;40, 167, 36; 40,171,36; 40,165,37; 40,169,36 ; 41, 160, 38 ;41, 163, 37 ;42, 157, 40 ;42, 158, 39 ;42, 165, 36 ; 42,162,42 ; 43, 155, 40 ;44, 154, 40 ;45, 153, 42];
hv = HV(Population, optimum);
disp([‘Hypervolume: ‘, num2str(hv)]);
in HV.m:
function score = HV(Population,optimum)
PopObj = vertcat(Population.best.objs);
… and the rest of the code from (https://github.com/BIMK/PlatEMO/blob/1274e2530e1c5afa928f3691c65af7d2f7efe099/PlatEMO/Metrics/HV.m) Does anybody know how can i apply this set of code (HV.m) from PlatEMO (https://github.com/BIMK/PlatEMO/blob/1274e2530e1c5afa928f3691c65af7d2f7efe099/PlatEMO/Metrics/HV.m)
I’ve tried to execute it with the population solutions obtained from my algorithm and the optimum values obtained across several benchmark dataset as follows, however the output for hypervolume value that i’ve got is extremely low, what could be the problem?
inputs:
solutions = [43,176,38;43,177,37;42,188,38;46,168,38;43,184,36;42,178,48;42,169,49;42,179,42];
Population.best = struct(‘objs’, []);
% Fill the structure array with the solutions
for i = 1:size(solutions, 1)
Population.best(i).objs = solutions(i, :);
end
optimum = [40, 162, 38 ; 40, 164, 37 ;40, 167, 36; 40,171,36; 40,165,37; 40,169,36 ; 41, 160, 38 ;41, 163, 37 ;42, 157, 40 ;42, 158, 39 ;42, 165, 36 ; 42,162,42 ; 43, 155, 40 ;44, 154, 40 ;45, 153, 42];
hv = HV(Population, optimum);
disp([‘Hypervolume: ‘, num2str(hv)]);
in HV.m:
function score = HV(Population,optimum)
PopObj = vertcat(Population.best.objs);
… and the rest of the code from (https://github.com/BIMK/PlatEMO/blob/1274e2530e1c5afa928f3691c65af7d2f7efe099/PlatEMO/Metrics/HV.m) transferred MATLAB Answers — New Questions
Hypervolume indicator with Yi Cao
I am working with Multi-objective optimization problem and i come across with this code (https://www.mathworks.com/matlabcentral/fileexchange/19651-hypervolume-indicator), however, does anyone know how to get the function ‘paretofront’ from the exisiting code to obtain the hypervolume value
thanksI am working with Multi-objective optimization problem and i come across with this code (https://www.mathworks.com/matlabcentral/fileexchange/19651-hypervolume-indicator), however, does anyone know how to get the function ‘paretofront’ from the exisiting code to obtain the hypervolume value
thanks I am working with Multi-objective optimization problem and i come across with this code (https://www.mathworks.com/matlabcentral/fileexchange/19651-hypervolume-indicator), however, does anyone know how to get the function ‘paretofront’ from the exisiting code to obtain the hypervolume value
thanks transferred MATLAB Answers — New Questions
how to display the calling relation ship between simulink function and function caller
hello, as follwoing system shows, how to configure to display the relation ship between function caller an simulink function in the system diagram.hello, as follwoing system shows, how to configure to display the relation ship between function caller an simulink function in the system diagram. hello, as follwoing system shows, how to configure to display the relation ship between function caller an simulink function in the system diagram. simulink function, function caller MATLAB Answers — New Questions
Antlion optimization algorithm for fuel cost optimization
How Can i use the antlion optimizer tool for fuel cost optimization for a thermal power plant If not possible, please i need a matlab code to do thatHow Can i use the antlion optimizer tool for fuel cost optimization for a thermal power plant If not possible, please i need a matlab code to do that How Can i use the antlion optimizer tool for fuel cost optimization for a thermal power plant If not possible, please i need a matlab code to do that antlion optimization MATLAB Answers — New Questions