Tag Archives: matlab
how to change the direction of this code from right falling into left to left falling into right
Post Content Post Content homework, graph MATLAB Answers — New Questions
array mask not being reset in application
In the attached app, there are 2 sliders for "set range low" and "set range high" which are used to change the scale of hte colorbar. The goal of doing this artifcats in the image.
Anything outside of the range of the colorbar is highlighted with the imdilate function in the mask which is then displayed as a replacement to the orignal image
When we click the buttons for "set range low" and "set range high", it should change the values of the image array so that anything outisde of the high and low limits is set to the actual high or low limit itself.
This seems to work, the problem is that the mask does not seem to reset. So after you click the buttons to "set the range low" in the image, if you go back to the slider and go outside of hte orignal range, there are still values that show up.
Im not sure what is going on, it seems to work ok in the matlab but not the application designer. Been stuck on this for an embarassing amount of time and could use a hand. thank you.
maxvalue = app.Sliderhigh.Value;
minvalue = app.Sliderlow.Value;
app.highEditField.Value = num2str(maxvalue);
app.lowEditField.Value= num2str(minvalue);
c = colorbar(app.UIAxes);
app.UIAxes.CLim = [minvalue maxvalue];
maska= app.a >maxvalue | app.a <minvalue ;
maskc = imdilate(maska,strel(‘disk’,25,0));
imagesc(maxvalue*maskc,’Parent’,app.UIAxes)In the attached app, there are 2 sliders for "set range low" and "set range high" which are used to change the scale of hte colorbar. The goal of doing this artifcats in the image.
Anything outside of the range of the colorbar is highlighted with the imdilate function in the mask which is then displayed as a replacement to the orignal image
When we click the buttons for "set range low" and "set range high", it should change the values of the image array so that anything outisde of the high and low limits is set to the actual high or low limit itself.
This seems to work, the problem is that the mask does not seem to reset. So after you click the buttons to "set the range low" in the image, if you go back to the slider and go outside of hte orignal range, there are still values that show up.
Im not sure what is going on, it seems to work ok in the matlab but not the application designer. Been stuck on this for an embarassing amount of time and could use a hand. thank you.
maxvalue = app.Sliderhigh.Value;
minvalue = app.Sliderlow.Value;
app.highEditField.Value = num2str(maxvalue);
app.lowEditField.Value= num2str(minvalue);
c = colorbar(app.UIAxes);
app.UIAxes.CLim = [minvalue maxvalue];
maska= app.a >maxvalue | app.a <minvalue ;
maskc = imdilate(maska,strel(‘disk’,25,0));
imagesc(maxvalue*maskc,’Parent’,app.UIAxes) In the attached app, there are 2 sliders for "set range low" and "set range high" which are used to change the scale of hte colorbar. The goal of doing this artifcats in the image.
Anything outside of the range of the colorbar is highlighted with the imdilate function in the mask which is then displayed as a replacement to the orignal image
When we click the buttons for "set range low" and "set range high", it should change the values of the image array so that anything outisde of the high and low limits is set to the actual high or low limit itself.
This seems to work, the problem is that the mask does not seem to reset. So after you click the buttons to "set the range low" in the image, if you go back to the slider and go outside of hte orignal range, there are still values that show up.
Im not sure what is going on, it seems to work ok in the matlab but not the application designer. Been stuck on this for an embarassing amount of time and could use a hand. thank you.
maxvalue = app.Sliderhigh.Value;
minvalue = app.Sliderlow.Value;
app.highEditField.Value = num2str(maxvalue);
app.lowEditField.Value= num2str(minvalue);
c = colorbar(app.UIAxes);
app.UIAxes.CLim = [minvalue maxvalue];
maska= app.a >maxvalue | app.a <minvalue ;
maskc = imdilate(maska,strel(‘disk’,25,0));
imagesc(maxvalue*maskc,’Parent’,app.UIAxes) application designer, mask MATLAB Answers — New Questions
How do I install and configure the network license manager for Polyspace products?
I have a concurrent license for my Polyspace products and I would like to setup the network license manager. How do I do so?I have a concurrent license for my Polyspace products and I would like to setup the network license manager. How do I do so? I have a concurrent license for my Polyspace products and I would like to setup the network license manager. How do I do so? MATLAB Answers — New Questions
how to solve illegal instruction while running the script
im using amd processor. while running the script from the editor it takes more and shows illegal instruction has been detected and matlab exist.im using amd processor. while running the script from the editor it takes more and shows illegal instruction has been detected and matlab exist. im using amd processor. while running the script from the editor it takes more and shows illegal instruction has been detected and matlab exist. script, instruction, environment variable MATLAB Answers — New Questions
AutomatedDrivingRadarSimulationExample does not work, due to helperAutoDrivingRadarSigProc>setupScenario
Hi, experts,
I am using R2024a and trying to run the example of AutomatedDrivingRadarSimulationExample by running the two commands below in the Command Window of matlab, but got error messages:
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
Please see the error messages below. Any idea why?
***************** Below is the output from "Command Window" of matlab ****************************
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
hpbw =
17.1800
drivingScenario requires Automated Driving Toolbox.
Error in helperAutoDrivingRadarSigProc>setupScenario (line 53)
scenario = drivingScenario;
Error in helperAutoDrivingRadarSigProc (line 12)
[scenario,egoCar,radarParams,tgts] = setupScenario(varargin{:});
Error in AutomatedDrivingRadarSimulationExample (line 138)
helperAutoDrivingRadarSigProc(‘Setup Scenario’,c,fc);
***************** Above is the output from "Command Window" of matlab ****************************Hi, experts,
I am using R2024a and trying to run the example of AutomatedDrivingRadarSimulationExample by running the two commands below in the Command Window of matlab, but got error messages:
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
Please see the error messages below. Any idea why?
***************** Below is the output from "Command Window" of matlab ****************************
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
hpbw =
17.1800
drivingScenario requires Automated Driving Toolbox.
Error in helperAutoDrivingRadarSigProc>setupScenario (line 53)
scenario = drivingScenario;
Error in helperAutoDrivingRadarSigProc (line 12)
[scenario,egoCar,radarParams,tgts] = setupScenario(varargin{:});
Error in AutomatedDrivingRadarSimulationExample (line 138)
helperAutoDrivingRadarSigProc(‘Setup Scenario’,c,fc);
***************** Above is the output from "Command Window" of matlab **************************** Hi, experts,
I am using R2024a and trying to run the example of AutomatedDrivingRadarSimulationExample by running the two commands below in the Command Window of matlab, but got error messages:
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
Please see the error messages below. Any idea why?
***************** Below is the output from "Command Window" of matlab ****************************
>> openExample(‘driving_radar/AutomatedDrivingRadarSimulationExample’)
>> AutomatedDrivingRadarSimulationExample
hpbw =
17.1800
drivingScenario requires Automated Driving Toolbox.
Error in helperAutoDrivingRadarSigProc>setupScenario (line 53)
scenario = drivingScenario;
Error in helperAutoDrivingRadarSigProc (line 12)
[scenario,egoCar,radarParams,tgts] = setupScenario(varargin{:});
Error in AutomatedDrivingRadarSimulationExample (line 138)
helperAutoDrivingRadarSigProc(‘Setup Scenario’,c,fc);
***************** Above is the output from "Command Window" of matlab **************************** radar, autodriving MATLAB Answers — New Questions
How to locked/unlocked cells in an Excel file?
Dear,
how can I lock/unlock cells in Excell file?
For example: file = ‘Fruits.xlsx’, Sheet = ‘Apple’, Range = ‘B4:B10’.
How is possible to lock the cells in range ‘B4:B10’ in my file and my sheet? The file and the sheet are unprotected.
Thank you very much? Jurij RiciDear,
how can I lock/unlock cells in Excell file?
For example: file = ‘Fruits.xlsx’, Sheet = ‘Apple’, Range = ‘B4:B10’.
How is possible to lock the cells in range ‘B4:B10’ in my file and my sheet? The file and the sheet are unprotected.
Thank you very much? Jurij Rici Dear,
how can I lock/unlock cells in Excell file?
For example: file = ‘Fruits.xlsx’, Sheet = ‘Apple’, Range = ‘B4:B10’.
How is possible to lock the cells in range ‘B4:B10’ in my file and my sheet? The file and the sheet are unprotected.
Thank you very much? Jurij Rici excel, locked cells MATLAB Answers — New Questions
MEAN OF A VARIABLE WITH RESPECT TO OTHER VARIABLES
I would like to find mean of the variable a25 other variable a6a7 and by year .
input int(year a6a7) long a25
2017 121 12000
2017 121 30000
2017 121 13000
2017 121 14000
2017 121 15000
2017 121 15000
2017 121 15000
2017 121 20000
2017 121 15000
2017 121 8000
2017 121 10000
2017 121 14000
2017 121 35000
2017 121 6000
2017 121 2000
2017 121 10000
2017 17 15000
2017 17 15000
2017 17 12000
2017 17 15000
2017 17 15000
2017 17 8000
2017 17 7000
2017 17 5000
2017 121 10000
2017 121 10000
2017 121 6000
2017 121 8000
2017 121 8000
2017 121 12000
2017 121 10000
2017 121 10000
2017 121 16000
2017 121 8000
2017 121 12000
2017 121 15000
2017 121 15000
2017 121 15000
2017 121 8000
2017 121 10000
2017 121 10000
2017 121 8000
2017 121 6000
2017 121 6000
2017 121 6000
2017 121 10000
2017 121 10000
2017 121 10000
2017 121 7000
2017 121 8000
2017 121 10000
2017 121 10000
2017 121 15000
2017 121 5000
2017 121 10000
2017 121 10000
2017 17 25000
2017 17 8000
2017 17 8000
2017 17 10000
2017 17 7000
2017 17 6000
2017 17 3500
2017 17 8000
2017 17 20000
2017 17 16000
2017 17 16000
2017 17 14000
2017 17 25000
2017 17 15000
2017 17 16000
2017 17 16000
2017 121 12000
2017 121 15000
2017 121 12000
2017 121 12000
2017 121 13000
2017 121 12000
2017 121 14000
2017 121 8000
2017 120 5000
2017 120 5000
2017 120 4000
2017 120 5000
2017 120 3000
2017 120 4000
2017 120 4000
2017 120 4000
2017 119 6000
2017 119 6000
2017 119 4000
2017 119 5000
2017 119 5000
2017 119 7000
2017 119 7000
2017 119 6000
2017 16 20000
2017 16 15000
2017 16 20000
2017 16 15000
end
[/CODE]I would like to find mean of the variable a25 other variable a6a7 and by year .
input int(year a6a7) long a25
2017 121 12000
2017 121 30000
2017 121 13000
2017 121 14000
2017 121 15000
2017 121 15000
2017 121 15000
2017 121 20000
2017 121 15000
2017 121 8000
2017 121 10000
2017 121 14000
2017 121 35000
2017 121 6000
2017 121 2000
2017 121 10000
2017 17 15000
2017 17 15000
2017 17 12000
2017 17 15000
2017 17 15000
2017 17 8000
2017 17 7000
2017 17 5000
2017 121 10000
2017 121 10000
2017 121 6000
2017 121 8000
2017 121 8000
2017 121 12000
2017 121 10000
2017 121 10000
2017 121 16000
2017 121 8000
2017 121 12000
2017 121 15000
2017 121 15000
2017 121 15000
2017 121 8000
2017 121 10000
2017 121 10000
2017 121 8000
2017 121 6000
2017 121 6000
2017 121 6000
2017 121 10000
2017 121 10000
2017 121 10000
2017 121 7000
2017 121 8000
2017 121 10000
2017 121 10000
2017 121 15000
2017 121 5000
2017 121 10000
2017 121 10000
2017 17 25000
2017 17 8000
2017 17 8000
2017 17 10000
2017 17 7000
2017 17 6000
2017 17 3500
2017 17 8000
2017 17 20000
2017 17 16000
2017 17 16000
2017 17 14000
2017 17 25000
2017 17 15000
2017 17 16000
2017 17 16000
2017 121 12000
2017 121 15000
2017 121 12000
2017 121 12000
2017 121 13000
2017 121 12000
2017 121 14000
2017 121 8000
2017 120 5000
2017 120 5000
2017 120 4000
2017 120 5000
2017 120 3000
2017 120 4000
2017 120 4000
2017 120 4000
2017 119 6000
2017 119 6000
2017 119 4000
2017 119 5000
2017 119 5000
2017 119 7000
2017 119 7000
2017 119 6000
2017 16 20000
2017 16 15000
2017 16 20000
2017 16 15000
end
[/CODE] I would like to find mean of the variable a25 other variable a6a7 and by year .
input int(year a6a7) long a25
2017 121 12000
2017 121 30000
2017 121 13000
2017 121 14000
2017 121 15000
2017 121 15000
2017 121 15000
2017 121 20000
2017 121 15000
2017 121 8000
2017 121 10000
2017 121 14000
2017 121 35000
2017 121 6000
2017 121 2000
2017 121 10000
2017 17 15000
2017 17 15000
2017 17 12000
2017 17 15000
2017 17 15000
2017 17 8000
2017 17 7000
2017 17 5000
2017 121 10000
2017 121 10000
2017 121 6000
2017 121 8000
2017 121 8000
2017 121 12000
2017 121 10000
2017 121 10000
2017 121 16000
2017 121 8000
2017 121 12000
2017 121 15000
2017 121 15000
2017 121 15000
2017 121 8000
2017 121 10000
2017 121 10000
2017 121 8000
2017 121 6000
2017 121 6000
2017 121 6000
2017 121 10000
2017 121 10000
2017 121 10000
2017 121 7000
2017 121 8000
2017 121 10000
2017 121 10000
2017 121 15000
2017 121 5000
2017 121 10000
2017 121 10000
2017 17 25000
2017 17 8000
2017 17 8000
2017 17 10000
2017 17 7000
2017 17 6000
2017 17 3500
2017 17 8000
2017 17 20000
2017 17 16000
2017 17 16000
2017 17 14000
2017 17 25000
2017 17 15000
2017 17 16000
2017 17 16000
2017 121 12000
2017 121 15000
2017 121 12000
2017 121 12000
2017 121 13000
2017 121 12000
2017 121 14000
2017 121 8000
2017 120 5000
2017 120 5000
2017 120 4000
2017 120 5000
2017 120 3000
2017 120 4000
2017 120 4000
2017 120 4000
2017 119 6000
2017 119 6000
2017 119 4000
2017 119 5000
2017 119 5000
2017 119 7000
2017 119 7000
2017 119 6000
2017 16 20000
2017 16 15000
2017 16 20000
2017 16 15000
end
[/CODE] mean, big data MATLAB Answers — New Questions
Solar PV System with MPPT Using Boost Converter
In the mentioned Official Simulink Model, I do not know whether the model is tested using Speedgoat through rapid control prototyping or not. Can anyone please let me know.In the mentioned Official Simulink Model, I do not know whether the model is tested using Speedgoat through rapid control prototyping or not. Can anyone please let me know. In the mentioned Official Simulink Model, I do not know whether the model is tested using Speedgoat through rapid control prototyping or not. Can anyone please let me know. speedgoat, transferred MATLAB Answers — New Questions
Plot – Remove axis ticks but keep grid lines
Hi,
I am producing a graph to view open source polysomnography data. I have several arrays in one plot window with an offset between them which is fairly standard. I wish to remove the y tick numbers as they aren’t required and get in the way of some additional lables. I would like to also include some x and y axis gridlines.
I have implemented the following code below, however the ‘set(gca,’ytick’,[])’ command makes the y gridlines not plot. How can I remove the ytick numbers on the y axis but keep the y gridlines?
Thanks in advance,
Christopher!
% Create a new empty figure
figure
% Remove y axis numbering
set(gca,’ytick’,[])
% Set major Grid lines
ax.GridLineStyle = ‘–‘;
ax.GridColor = ‘b’;
ax.GridAlpha = 1;
grid on;
% Set minor Grid lines
ax.MinorGridLineStyle = ‘-‘;
ax.MinorGridColor = ‘b’;
ax.MinorGridAlpha = 0.5;
grid minor;Hi,
I am producing a graph to view open source polysomnography data. I have several arrays in one plot window with an offset between them which is fairly standard. I wish to remove the y tick numbers as they aren’t required and get in the way of some additional lables. I would like to also include some x and y axis gridlines.
I have implemented the following code below, however the ‘set(gca,’ytick’,[])’ command makes the y gridlines not plot. How can I remove the ytick numbers on the y axis but keep the y gridlines?
Thanks in advance,
Christopher!
% Create a new empty figure
figure
% Remove y axis numbering
set(gca,’ytick’,[])
% Set major Grid lines
ax.GridLineStyle = ‘–‘;
ax.GridColor = ‘b’;
ax.GridAlpha = 1;
grid on;
% Set minor Grid lines
ax.MinorGridLineStyle = ‘-‘;
ax.MinorGridColor = ‘b’;
ax.MinorGridAlpha = 0.5;
grid minor; Hi,
I am producing a graph to view open source polysomnography data. I have several arrays in one plot window with an offset between them which is fairly standard. I wish to remove the y tick numbers as they aren’t required and get in the way of some additional lables. I would like to also include some x and y axis gridlines.
I have implemented the following code below, however the ‘set(gca,’ytick’,[])’ command makes the y gridlines not plot. How can I remove the ytick numbers on the y axis but keep the y gridlines?
Thanks in advance,
Christopher!
% Create a new empty figure
figure
% Remove y axis numbering
set(gca,’ytick’,[])
% Set major Grid lines
ax.GridLineStyle = ‘–‘;
ax.GridColor = ‘b’;
ax.GridAlpha = 1;
grid on;
% Set minor Grid lines
ax.MinorGridLineStyle = ‘-‘;
ax.MinorGridColor = ‘b’;
ax.MinorGridAlpha = 0.5;
grid minor; plot, tick, gridline MATLAB Answers — New Questions
PPO training Stopped Learning.
I am trying to train the rotatry inverted pendulum enviroment using a PPO agent. It’s working… but It’s reaching a limit and not learnign past this limit. I am not too sure why. Newbie to RL here so go easy on me :). I think it’s something to do with the yellow line, Q0. Also it could be reaching a local optima, but I don’t think this is the problem. I think the problem is with Q0 not getting past 100 and the agent not being able to extract more useful info. Hopefully, someone whith a little more experinace has something to say!
mdl = "rlQubeServoModel";
open_system(mdl)
theta_limit = 5*pi/8;
dtheta_limit = 30;
volt_limit = 12;
Ts = 0.005;
rng(22)
obsInfo = rlNumericSpec([7 1]);
actInfo = rlNumericSpec([1 1],UpperLimit=1,LowerLimit=-1);
agentBlk = mdl + "/RL Agent";
simEnv = rlSimulinkEnv(mdl,agentBlk,obsInfo,actInfo);
numObs = prod(obsInfo.Dimension);
criticLayerSizes = [400 300];
actorLayerSizes = [400 300];
% critic:
criticNetwork = [
featureInputLayer(numObs)
fullyConnectedLayer(criticLayerSizes(1), …
Weights=sqrt(2/numObs)*…
(rand(criticLayerSizes(1),numObs)-0.5), …
Bias=1e-3*ones(criticLayerSizes(1),1))
reluLayer
fullyConnectedLayer(criticLayerSizes(2), …
Weights=sqrt(2/criticLayerSizes(1))*…
(rand(criticLayerSizes(2),criticLayerSizes(1))-0.5), …
Bias=1e-3*ones(criticLayerSizes(2),1))
reluLayer
fullyConnectedLayer(1, …
Weights=sqrt(2/criticLayerSizes(2))* …
(rand(1,criticLayerSizes(2))-0.5), …
Bias=1e-3)
];
criticNetwork = dlnetwork(criticNetwork);
summary(criticNetwork)
critic = rlValueFunction(criticNetwork,obsInfo);
% actor:
% Input path layers
inPath = [
featureInputLayer( …
prod(obsInfo.Dimension), …
Name="netOin")
fullyConnectedLayer( …
prod(actInfo.Dimension), …
Name="infc")
];
% Path layers for mean value
meanPath = [
tanhLayer(Name="tanhMean");
fullyConnectedLayer(prod(actInfo.Dimension));
scalingLayer(Name="scale", …
Scale=actInfo.UpperLimit)
];
% Path layers for standard deviations
% Using softplus layer to make them non negative
sdevPath = [
tanhLayer(Name="tanhStdv");
fullyConnectedLayer(prod(actInfo.Dimension));
softplusLayer(Name="splus")
];
net = dlnetwork();
net = addLayers(net,inPath);
net = addLayers(net,meanPath);
net = addLayers(net,sdevPath);
net = connectLayers(net,"infc","tanhMean/in");
net = connectLayers(net,"infc","tanhStdv/in");
plot(net)
net = initialize(net);
summary(net)
actor = rlContinuousGaussianActor(net, obsInfo, actInfo, …
ActionMeanOutputNames="scale",…
ActionStandardDeviationOutputNames="splus",…
ObservationInputNames="netOin");
actorOpts = rlOptimizerOptions(LearnRate=1e-4);
criticOpts = rlOptimizerOptions(LearnRate=1e-4);
agentOpts = rlPPOAgentOptions(…
ExperienceHorizon=600,…
ClipFactor=0.02,…
EntropyLossWeight=0.01,…
ActorOptimizerOptions=actorOpts,…
CriticOptimizerOptions=criticOpts,…
NumEpoch=3,…
AdvantageEstimateMethod="gae",…
GAEFactor=0.95,…
SampleTime=0.1,…
DiscountFactor=0.997);
agent = rlPPOAgent(actor,critic,agentOpts);
trainOpts = rlTrainingOptions(…
MaxEpisodes=20000,…
MaxStepsPerEpisode=600,…
Plots="training-progress",…
StopTrainingCriteria="AverageReward",…
StopTrainingValue=430,…
ScoreAveragingWindowLength=100);
trainingStats = train(agent, simEnv, trainOpts);
thanks in advanced!I am trying to train the rotatry inverted pendulum enviroment using a PPO agent. It’s working… but It’s reaching a limit and not learnign past this limit. I am not too sure why. Newbie to RL here so go easy on me :). I think it’s something to do with the yellow line, Q0. Also it could be reaching a local optima, but I don’t think this is the problem. I think the problem is with Q0 not getting past 100 and the agent not being able to extract more useful info. Hopefully, someone whith a little more experinace has something to say!
mdl = "rlQubeServoModel";
open_system(mdl)
theta_limit = 5*pi/8;
dtheta_limit = 30;
volt_limit = 12;
Ts = 0.005;
rng(22)
obsInfo = rlNumericSpec([7 1]);
actInfo = rlNumericSpec([1 1],UpperLimit=1,LowerLimit=-1);
agentBlk = mdl + "/RL Agent";
simEnv = rlSimulinkEnv(mdl,agentBlk,obsInfo,actInfo);
numObs = prod(obsInfo.Dimension);
criticLayerSizes = [400 300];
actorLayerSizes = [400 300];
% critic:
criticNetwork = [
featureInputLayer(numObs)
fullyConnectedLayer(criticLayerSizes(1), …
Weights=sqrt(2/numObs)*…
(rand(criticLayerSizes(1),numObs)-0.5), …
Bias=1e-3*ones(criticLayerSizes(1),1))
reluLayer
fullyConnectedLayer(criticLayerSizes(2), …
Weights=sqrt(2/criticLayerSizes(1))*…
(rand(criticLayerSizes(2),criticLayerSizes(1))-0.5), …
Bias=1e-3*ones(criticLayerSizes(2),1))
reluLayer
fullyConnectedLayer(1, …
Weights=sqrt(2/criticLayerSizes(2))* …
(rand(1,criticLayerSizes(2))-0.5), …
Bias=1e-3)
];
criticNetwork = dlnetwork(criticNetwork);
summary(criticNetwork)
critic = rlValueFunction(criticNetwork,obsInfo);
% actor:
% Input path layers
inPath = [
featureInputLayer( …
prod(obsInfo.Dimension), …
Name="netOin")
fullyConnectedLayer( …
prod(actInfo.Dimension), …
Name="infc")
];
% Path layers for mean value
meanPath = [
tanhLayer(Name="tanhMean");
fullyConnectedLayer(prod(actInfo.Dimension));
scalingLayer(Name="scale", …
Scale=actInfo.UpperLimit)
];
% Path layers for standard deviations
% Using softplus layer to make them non negative
sdevPath = [
tanhLayer(Name="tanhStdv");
fullyConnectedLayer(prod(actInfo.Dimension));
softplusLayer(Name="splus")
];
net = dlnetwork();
net = addLayers(net,inPath);
net = addLayers(net,meanPath);
net = addLayers(net,sdevPath);
net = connectLayers(net,"infc","tanhMean/in");
net = connectLayers(net,"infc","tanhStdv/in");
plot(net)
net = initialize(net);
summary(net)
actor = rlContinuousGaussianActor(net, obsInfo, actInfo, …
ActionMeanOutputNames="scale",…
ActionStandardDeviationOutputNames="splus",…
ObservationInputNames="netOin");
actorOpts = rlOptimizerOptions(LearnRate=1e-4);
criticOpts = rlOptimizerOptions(LearnRate=1e-4);
agentOpts = rlPPOAgentOptions(…
ExperienceHorizon=600,…
ClipFactor=0.02,…
EntropyLossWeight=0.01,…
ActorOptimizerOptions=actorOpts,…
CriticOptimizerOptions=criticOpts,…
NumEpoch=3,…
AdvantageEstimateMethod="gae",…
GAEFactor=0.95,…
SampleTime=0.1,…
DiscountFactor=0.997);
agent = rlPPOAgent(actor,critic,agentOpts);
trainOpts = rlTrainingOptions(…
MaxEpisodes=20000,…
MaxStepsPerEpisode=600,…
Plots="training-progress",…
StopTrainingCriteria="AverageReward",…
StopTrainingValue=430,…
ScoreAveragingWindowLength=100);
trainingStats = train(agent, simEnv, trainOpts);
thanks in advanced! I am trying to train the rotatry inverted pendulum enviroment using a PPO agent. It’s working… but It’s reaching a limit and not learnign past this limit. I am not too sure why. Newbie to RL here so go easy on me :). I think it’s something to do with the yellow line, Q0. Also it could be reaching a local optima, but I don’t think this is the problem. I think the problem is with Q0 not getting past 100 and the agent not being able to extract more useful info. Hopefully, someone whith a little more experinace has something to say!
mdl = "rlQubeServoModel";
open_system(mdl)
theta_limit = 5*pi/8;
dtheta_limit = 30;
volt_limit = 12;
Ts = 0.005;
rng(22)
obsInfo = rlNumericSpec([7 1]);
actInfo = rlNumericSpec([1 1],UpperLimit=1,LowerLimit=-1);
agentBlk = mdl + "/RL Agent";
simEnv = rlSimulinkEnv(mdl,agentBlk,obsInfo,actInfo);
numObs = prod(obsInfo.Dimension);
criticLayerSizes = [400 300];
actorLayerSizes = [400 300];
% critic:
criticNetwork = [
featureInputLayer(numObs)
fullyConnectedLayer(criticLayerSizes(1), …
Weights=sqrt(2/numObs)*…
(rand(criticLayerSizes(1),numObs)-0.5), …
Bias=1e-3*ones(criticLayerSizes(1),1))
reluLayer
fullyConnectedLayer(criticLayerSizes(2), …
Weights=sqrt(2/criticLayerSizes(1))*…
(rand(criticLayerSizes(2),criticLayerSizes(1))-0.5), …
Bias=1e-3*ones(criticLayerSizes(2),1))
reluLayer
fullyConnectedLayer(1, …
Weights=sqrt(2/criticLayerSizes(2))* …
(rand(1,criticLayerSizes(2))-0.5), …
Bias=1e-3)
];
criticNetwork = dlnetwork(criticNetwork);
summary(criticNetwork)
critic = rlValueFunction(criticNetwork,obsInfo);
% actor:
% Input path layers
inPath = [
featureInputLayer( …
prod(obsInfo.Dimension), …
Name="netOin")
fullyConnectedLayer( …
prod(actInfo.Dimension), …
Name="infc")
];
% Path layers for mean value
meanPath = [
tanhLayer(Name="tanhMean");
fullyConnectedLayer(prod(actInfo.Dimension));
scalingLayer(Name="scale", …
Scale=actInfo.UpperLimit)
];
% Path layers for standard deviations
% Using softplus layer to make them non negative
sdevPath = [
tanhLayer(Name="tanhStdv");
fullyConnectedLayer(prod(actInfo.Dimension));
softplusLayer(Name="splus")
];
net = dlnetwork();
net = addLayers(net,inPath);
net = addLayers(net,meanPath);
net = addLayers(net,sdevPath);
net = connectLayers(net,"infc","tanhMean/in");
net = connectLayers(net,"infc","tanhStdv/in");
plot(net)
net = initialize(net);
summary(net)
actor = rlContinuousGaussianActor(net, obsInfo, actInfo, …
ActionMeanOutputNames="scale",…
ActionStandardDeviationOutputNames="splus",…
ObservationInputNames="netOin");
actorOpts = rlOptimizerOptions(LearnRate=1e-4);
criticOpts = rlOptimizerOptions(LearnRate=1e-4);
agentOpts = rlPPOAgentOptions(…
ExperienceHorizon=600,…
ClipFactor=0.02,…
EntropyLossWeight=0.01,…
ActorOptimizerOptions=actorOpts,…
CriticOptimizerOptions=criticOpts,…
NumEpoch=3,…
AdvantageEstimateMethod="gae",…
GAEFactor=0.95,…
SampleTime=0.1,…
DiscountFactor=0.997);
agent = rlPPOAgent(actor,critic,agentOpts);
trainOpts = rlTrainingOptions(…
MaxEpisodes=20000,…
MaxStepsPerEpisode=600,…
Plots="training-progress",…
StopTrainingCriteria="AverageReward",…
StopTrainingValue=430,…
ScoreAveragingWindowLength=100);
trainingStats = train(agent, simEnv, trainOpts);
thanks in advanced! ppo, rl, machine learning, ml, help, code, deep learning MATLAB Answers — New Questions
Generate a PWM in FPGA using a customised carrier.
Hi Kiran
Hope you doing well. I have seen your helpful answers for everyone. However , i have an issue and wish if you can help. I am trying to generate a PWM pulses using Speedgoat model IO334 FPGA. I have to customise an up-down counter ( as a carrier) to compare with a reference signal in order to obtain our PWM signals to drive a convertor. This counter must be HDL supported.
Keywords : Clock cycle of the speed goat is 10 nanos . Resulation can be 2^32-1.
I will appreciate if you can helpHi Kiran
Hope you doing well. I have seen your helpful answers for everyone. However , i have an issue and wish if you can help. I am trying to generate a PWM pulses using Speedgoat model IO334 FPGA. I have to customise an up-down counter ( as a carrier) to compare with a reference signal in order to obtain our PWM signals to drive a convertor. This counter must be HDL supported.
Keywords : Clock cycle of the speed goat is 10 nanos . Resulation can be 2^32-1.
I will appreciate if you can help Hi Kiran
Hope you doing well. I have seen your helpful answers for everyone. However , i have an issue and wish if you can help. I am trying to generate a PWM pulses using Speedgoat model IO334 FPGA. I have to customise an up-down counter ( as a carrier) to compare with a reference signal in order to obtain our PWM signals to drive a convertor. This counter must be HDL supported.
Keywords : Clock cycle of the speed goat is 10 nanos . Resulation can be 2^32-1.
I will appreciate if you can help pwm, fpga MATLAB Answers — New Questions
Generate the motion (Trajectory) of a sphere (or point) with given velocity value
Hi. I have this file ‘DATA’. The first 3 columns are the nodes in space (X,Y,Z in [m]). The 4th column is not of interest. The fifth column is the velocity in [m/s].
Is it possible to visualize the motion (green direction) of a sphere (e.g., the red one in the figure) moving following the velocity values in the fifth column of DATA?
load("DATA.mat");
figure
plot3(DATA(:,1),DATA(:,2),DATA(:,3),’-k’,’LineWidth’,0.1);
hold on
plot3(DATA(1,1),DATA(1,2),DATA(1,3),’r.’,’MarkerSize’,30);
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid offHi. I have this file ‘DATA’. The first 3 columns are the nodes in space (X,Y,Z in [m]). The 4th column is not of interest. The fifth column is the velocity in [m/s].
Is it possible to visualize the motion (green direction) of a sphere (e.g., the red one in the figure) moving following the velocity values in the fifth column of DATA?
load("DATA.mat");
figure
plot3(DATA(:,1),DATA(:,2),DATA(:,3),’-k’,’LineWidth’,0.1);
hold on
plot3(DATA(1,1),DATA(1,2),DATA(1,3),’r.’,’MarkerSize’,30);
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid off Hi. I have this file ‘DATA’. The first 3 columns are the nodes in space (X,Y,Z in [m]). The 4th column is not of interest. The fifth column is the velocity in [m/s].
Is it possible to visualize the motion (green direction) of a sphere (e.g., the red one in the figure) moving following the velocity values in the fifth column of DATA?
load("DATA.mat");
figure
plot3(DATA(:,1),DATA(:,2),DATA(:,3),’-k’,’LineWidth’,0.1);
hold on
plot3(DATA(1,1),DATA(1,2),DATA(1,3),’r.’,’MarkerSize’,30);
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid off motion, trajectory MATLAB Answers — New Questions
I needed to do the Simulation of Concentrated Solar Power (CSP) in Simulink, would like to if any have done this before and also if existing model is there it would be help!
I would like to know about the simulation of CSP in simulink.
Thanks!!I would like to know about the simulation of CSP in simulink.
Thanks!! I would like to know about the simulation of CSP in simulink.
Thanks!! concentrated solar power, csp, simulink, simulation MATLAB Answers — New Questions
Supress tcpipclient readline warning for a empty answer
I want to supres the warning: "Warning: The specified amount of data was not returned within the Timeout period for ‘readline’.
‘tcpclient’ unable to read any data. For more information on possible reasons, see tcpclient Read Warnings.". I am using tcpipclient and the readline function.I want to supres the warning: "Warning: The specified amount of data was not returned within the Timeout period for ‘readline’.
‘tcpclient’ unable to read any data. For more information on possible reasons, see tcpclient Read Warnings.". I am using tcpipclient and the readline function. I want to supres the warning: "Warning: The specified amount of data was not returned within the Timeout period for ‘readline’.
‘tcpclient’ unable to read any data. For more information on possible reasons, see tcpclient Read Warnings.". I am using tcpipclient and the readline function. tcpipclient, warning MATLAB Answers — New Questions
How to encounter a 1e-7 decimal place error when using single for calculations in Simulink?
I created a model in Simulink for testing the Simulink test tool. The division module was used in the model, and I found that the Divide module introduced calculation accuracy, which caused to fail the Simulink test. How can discard data with 1e-7 or other specified precision?
I already know that in Simulink test cases, error precision can be set to ignore calculation errors of specified precision. But if multiplication continues after the division module, the calculation error will accumulate and exceed the set error accuracy.
Looking forward to everyone’s replyI created a model in Simulink for testing the Simulink test tool. The division module was used in the model, and I found that the Divide module introduced calculation accuracy, which caused to fail the Simulink test. How can discard data with 1e-7 or other specified precision?
I already know that in Simulink test cases, error precision can be set to ignore calculation errors of specified precision. But if multiplication continues after the division module, the calculation error will accumulate and exceed the set error accuracy.
Looking forward to everyone’s reply I created a model in Simulink for testing the Simulink test tool. The division module was used in the model, and I found that the Divide module introduced calculation accuracy, which caused to fail the Simulink test. How can discard data with 1e-7 or other specified precision?
I already know that in Simulink test cases, error precision can be set to ignore calculation errors of specified precision. But if multiplication continues after the division module, the calculation error will accumulate and exceed the set error accuracy.
Looking forward to everyone’s reply simulink, simulink test, diviation MATLAB Answers — New Questions
Custom data types and constraints with genetic algorithms
Hello everybody,
I’m trying to implement a genetic algorithm that works with custom data types in MATLAB. Each chromosome of the population is made of two parts: a string and a vector of integers.
The string part is the binary representation of a number and I need to perform admissibility checks over it after crossover and mutation operations in order to avoid that the number represented could exceed a certain value.
I’ve followed this example for working with custom data types but I still have a question: how do I pass the max value as parameter to crossover and mutation functions? And, more generally, is there a way to pass any extra parameter to these functions?
For now I’m using global variables, but this feels a very bad idea and I’d like to find out which is the right way to do what I need.
Thanks in advance!Hello everybody,
I’m trying to implement a genetic algorithm that works with custom data types in MATLAB. Each chromosome of the population is made of two parts: a string and a vector of integers.
The string part is the binary representation of a number and I need to perform admissibility checks over it after crossover and mutation operations in order to avoid that the number represented could exceed a certain value.
I’ve followed this example for working with custom data types but I still have a question: how do I pass the max value as parameter to crossover and mutation functions? And, more generally, is there a way to pass any extra parameter to these functions?
For now I’m using global variables, but this feels a very bad idea and I’d like to find out which is the right way to do what I need.
Thanks in advance! Hello everybody,
I’m trying to implement a genetic algorithm that works with custom data types in MATLAB. Each chromosome of the population is made of two parts: a string and a vector of integers.
The string part is the binary representation of a number and I need to perform admissibility checks over it after crossover and mutation operations in order to avoid that the number represented could exceed a certain value.
I’ve followed this example for working with custom data types but I still have a question: how do I pass the max value as parameter to crossover and mutation functions? And, more generally, is there a way to pass any extra parameter to these functions?
For now I’m using global variables, but this feels a very bad idea and I’d like to find out which is the right way to do what I need.
Thanks in advance! genetic algorithm MATLAB Answers — New Questions
When the yaw angle exceeds 90° the robot cannot maintain balance states in Simscape
I used simscape to simulate,modeling and control of a wheeled biped robot. I used LQR to calculate the torque for the robot to maintain balance states. I used a lot of balls to simulate the contact between the tire and the ground. Everything is ok when the yaw angle of the robot is less than 90 degree.
here is yaw 0 dgree
here is yaw 60 dgree
when the yaw angle is greater than 90 degree, can’t maintain balance.
here is yaw 90 dgree
here is yaw 180 dgree
when I change the positive and negative sign of the both hub torque at 180 degree yaw angle , everything return to normal as the same as the 0 degree.
here is yaw 180 dgree but change the positive and negative sign of the both hub torque
What’s happaning? Is it because of the spatial contact force?I used simscape to simulate,modeling and control of a wheeled biped robot. I used LQR to calculate the torque for the robot to maintain balance states. I used a lot of balls to simulate the contact between the tire and the ground. Everything is ok when the yaw angle of the robot is less than 90 degree.
here is yaw 0 dgree
here is yaw 60 dgree
when the yaw angle is greater than 90 degree, can’t maintain balance.
here is yaw 90 dgree
here is yaw 180 dgree
when I change the positive and negative sign of the both hub torque at 180 degree yaw angle , everything return to normal as the same as the 0 degree.
here is yaw 180 dgree but change the positive and negative sign of the both hub torque
What’s happaning? Is it because of the spatial contact force? I used simscape to simulate,modeling and control of a wheeled biped robot. I used LQR to calculate the torque for the robot to maintain balance states. I used a lot of balls to simulate the contact between the tire and the ground. Everything is ok when the yaw angle of the robot is less than 90 degree.
here is yaw 0 dgree
here is yaw 60 dgree
when the yaw angle is greater than 90 degree, can’t maintain balance.
here is yaw 90 dgree
here is yaw 180 dgree
when I change the positive and negative sign of the both hub torque at 180 degree yaw angle , everything return to normal as the same as the 0 degree.
here is yaw 180 dgree but change the positive and negative sign of the both hub torque
What’s happaning? Is it because of the spatial contact force? spatial contact force, robot, simscape MATLAB Answers — New Questions
Combine multiple images (imfuse)
Hi, I am trying to dispaly 3 images using the below command. My A, B, C are in the format of 656 x 875 x 3 unit 8. I think the error is because of unit 8 format. I tried imfuse() as well, although it works for two images, but not for three images.
A = imread(‘1.bmp’);
B = imread(‘2.bmp’);
C = imread(‘3.bmp’);
overlay_im = cat(3, A, B, C);
imshow(overlay_im);
However, the above code throws below error
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({‘Parent’,’Border’,’Reduce’},preparsed_varargin{:});
Error in image_comb (line 276)
imshow(overlay_im);Hi, I am trying to dispaly 3 images using the below command. My A, B, C are in the format of 656 x 875 x 3 unit 8. I think the error is because of unit 8 format. I tried imfuse() as well, although it works for two images, but not for three images.
A = imread(‘1.bmp’);
B = imread(‘2.bmp’);
C = imread(‘3.bmp’);
overlay_im = cat(3, A, B, C);
imshow(overlay_im);
However, the above code throws below error
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({‘Parent’,’Border’,’Reduce’},preparsed_varargin{:});
Error in image_comb (line 276)
imshow(overlay_im); Hi, I am trying to dispaly 3 images using the below command. My A, B, C are in the format of 656 x 875 x 3 unit 8. I think the error is because of unit 8 format. I tried imfuse() as well, although it works for two images, but not for three images.
A = imread(‘1.bmp’);
B = imread(‘2.bmp’);
C = imread(‘3.bmp’);
overlay_im = cat(3, A, B, C);
imshow(overlay_im);
However, the above code throws below error
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({‘Parent’,’Border’,’Reduce’},preparsed_varargin{:});
Error in image_comb (line 276)
imshow(overlay_im); imfuse, display multiple images, combine images, imshowpair(), cat MATLAB Answers — New Questions
How to calculate scores when using pcacov?
I want to perform PCA analysis. When using pcacov function, it is not returned the scores. Could any of you guys help me with this problem? I know that using pca function scores are returned. But I am not using pca function because I want to perform PCA analysis using the Spearman correlation matrix obtained instead of Pearson. Thanks a lot for your help.I want to perform PCA analysis. When using pcacov function, it is not returned the scores. Could any of you guys help me with this problem? I know that using pca function scores are returned. But I am not using pca function because I want to perform PCA analysis using the Spearman correlation matrix obtained instead of Pearson. Thanks a lot for your help. I want to perform PCA analysis. When using pcacov function, it is not returned the scores. Could any of you guys help me with this problem? I know that using pca function scores are returned. But I am not using pca function because I want to perform PCA analysis using the Spearman correlation matrix obtained instead of Pearson. Thanks a lot for your help. pca, scores, corr MATLAB Answers — New Questions
RoadRunner shape file load
I would like to load a shapefile (.shp) into Roadrunner, and while I can verify that the map appears correctly in QGIS, when I load the .shp and .prj files into Roadrunner, some parts are corrupted and not loaded properly. What could be the cause of this issue?
Thank you
(RoadRunner 2024a)I would like to load a shapefile (.shp) into Roadrunner, and while I can verify that the map appears correctly in QGIS, when I load the .shp and .prj files into Roadrunner, some parts are corrupted and not loaded properly. What could be the cause of this issue?
Thank you
(RoadRunner 2024a) I would like to load a shapefile (.shp) into Roadrunner, and while I can verify that the map appears correctly in QGIS, when I load the .shp and .prj files into Roadrunner, some parts are corrupted and not loaded properly. What could be the cause of this issue?
Thank you
(RoadRunner 2024a) #roadrunner, #shp MATLAB Answers — New Questions