Tag Archives: matlab
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
Solving a large system takes too much memory?
Suppose i have a sparse matrix M with the following properties:
size(M) -> 100000 100000
sprank(M) -> 99236
nnz(M) -> 499987
numel(M) -> 1.0000e+10
who’s(‘M’) -> 8.4mb
How come solving the system takes way more than 8GB of RAM?
I’m using the following code (provided at http://www.mathworks.com/moler/exm/chapters/pagerank.pdf
function x = pagerank(G,p)
G = G – diag(diag(G));
[n,n] = size(G);
c = full(sum(G,1));
r = full(sum(G,2));
% Scale column sums to be 1 (or 0 where there are no out links).
k = find(c~=0);
D = sparse(k,k,1./c(k),n,n);
% Solve (I – p*G*D)*x = e
e = ones(n,1);
I = speye(n,n);
x = (I – p*G*D)e;
% Normalize so that sum(x) == 1.
x = x/sum(x);`Suppose i have a sparse matrix M with the following properties:
size(M) -> 100000 100000
sprank(M) -> 99236
nnz(M) -> 499987
numel(M) -> 1.0000e+10
who’s(‘M’) -> 8.4mb
How come solving the system takes way more than 8GB of RAM?
I’m using the following code (provided at http://www.mathworks.com/moler/exm/chapters/pagerank.pdf
function x = pagerank(G,p)
G = G – diag(diag(G));
[n,n] = size(G);
c = full(sum(G,1));
r = full(sum(G,2));
% Scale column sums to be 1 (or 0 where there are no out links).
k = find(c~=0);
D = sparse(k,k,1./c(k),n,n);
% Solve (I – p*G*D)*x = e
e = ones(n,1);
I = speye(n,n);
x = (I – p*G*D)e;
% Normalize so that sum(x) == 1.
x = x/sum(x);` Suppose i have a sparse matrix M with the following properties:
size(M) -> 100000 100000
sprank(M) -> 99236
nnz(M) -> 499987
numel(M) -> 1.0000e+10
who’s(‘M’) -> 8.4mb
How come solving the system takes way more than 8GB of RAM?
I’m using the following code (provided at http://www.mathworks.com/moler/exm/chapters/pagerank.pdf
function x = pagerank(G,p)
G = G – diag(diag(G));
[n,n] = size(G);
c = full(sum(G,1));
r = full(sum(G,2));
% Scale column sums to be 1 (or 0 where there are no out links).
k = find(c~=0);
D = sparse(k,k,1./c(k),n,n);
% Solve (I – p*G*D)*x = e
e = ones(n,1);
I = speye(n,n);
x = (I – p*G*D)e;
% Normalize so that sum(x) == 1.
x = x/sum(x);` matrix, solve, memory MATLAB Answers — New Questions
Unable to read MAT-file
hi all, I can not open the mat file (attached) in matlab while using load
Error using load
Unable to read MAT-file . File might be corrupt.
I already checked the ans here: https://www.mathworks.com/matlabcentral/answers/178877-unable-to-read-mat-file-file-may-be-corrupt
but it’s not work for me
Thankshi all, I can not open the mat file (attached) in matlab while using load
Error using load
Unable to read MAT-file . File might be corrupt.
I already checked the ans here: https://www.mathworks.com/matlabcentral/answers/178877-unable-to-read-mat-file-file-may-be-corrupt
but it’s not work for me
Thanks hi all, I can not open the mat file (attached) in matlab while using load
Error using load
Unable to read MAT-file . File might be corrupt.
I already checked the ans here: https://www.mathworks.com/matlabcentral/answers/178877-unable-to-read-mat-file-file-may-be-corrupt
but it’s not work for me
Thanks load MATLAB Answers — New Questions
cwtfilterbank magnitude linear scale
I am using the cwtfilterbank function to generate a scalogram from a signal. However, the frequencies on the Y-axis of the scalogram are not linear. I have read the documentation for cwtfilterbank, but I couldn’t find a direct solution. What changes can I make to achieve a linear frequency scale on the scalogram?
fb = cwtfilterbank(‘SignalLength’,signalLength,’Wavelet’,’amor’,’SamplingFrequency’,Fs,’VoicesPerOctave’,48, ‘FrequencyLimits’, [0 40])
[wt,f] = fb.wt(sig);
im = ind2rgb(im2uint8(rescale(abs(wt))),jet(256));I am using the cwtfilterbank function to generate a scalogram from a signal. However, the frequencies on the Y-axis of the scalogram are not linear. I have read the documentation for cwtfilterbank, but I couldn’t find a direct solution. What changes can I make to achieve a linear frequency scale on the scalogram?
fb = cwtfilterbank(‘SignalLength’,signalLength,’Wavelet’,’amor’,’SamplingFrequency’,Fs,’VoicesPerOctave’,48, ‘FrequencyLimits’, [0 40])
[wt,f] = fb.wt(sig);
im = ind2rgb(im2uint8(rescale(abs(wt))),jet(256)); I am using the cwtfilterbank function to generate a scalogram from a signal. However, the frequencies on the Y-axis of the scalogram are not linear. I have read the documentation for cwtfilterbank, but I couldn’t find a direct solution. What changes can I make to achieve a linear frequency scale on the scalogram?
fb = cwtfilterbank(‘SignalLength’,signalLength,’Wavelet’,’amor’,’SamplingFrequency’,Fs,’VoicesPerOctave’,48, ‘FrequencyLimits’, [0 40])
[wt,f] = fb.wt(sig);
im = ind2rgb(im2uint8(rescale(abs(wt))),jet(256)); wavelet, cwt, signal processing, continuous wavelet transforms MATLAB Answers — New Questions
Verilog Verification by using UVM without FPGA Circuit Board. Possible?
Hi all,
Seeking for you advise if I want to use simulink to do UVM for RTL Verilog verification.
I have seen this from Matlab website.
https://www.mathworks.com/help/hdlverifier/ug/fpga-in-the-loop-fil-simulation.html
Seem like to do this verification, I require FPGA Circuit Board.
Would it be possible I do it without FPGA Board, just load my code adn do the verification through Simulink.
ThanksHi all,
Seeking for you advise if I want to use simulink to do UVM for RTL Verilog verification.
I have seen this from Matlab website.
https://www.mathworks.com/help/hdlverifier/ug/fpga-in-the-loop-fil-simulation.html
Seem like to do this verification, I require FPGA Circuit Board.
Would it be possible I do it without FPGA Board, just load my code adn do the verification through Simulink.
Thanks Hi all,
Seeking for you advise if I want to use simulink to do UVM for RTL Verilog verification.
I have seen this from Matlab website.
https://www.mathworks.com/help/hdlverifier/ug/fpga-in-the-loop-fil-simulation.html
Seem like to do this verification, I require FPGA Circuit Board.
Would it be possible I do it without FPGA Board, just load my code adn do the verification through Simulink.
Thanks transferred MATLAB Answers — New Questions
Need help in learning about adaptive autosar
Hello Community
I want to learn about adaptive autosar using MATLAB but since there are so many documentation , I am confused from where to start. It would be helpful if someone could guide from where to start.Hello Community
I want to learn about adaptive autosar using MATLAB but since there are so many documentation , I am confused from where to start. It would be helpful if someone could guide from where to start. Hello Community
I want to learn about adaptive autosar using MATLAB but since there are so many documentation , I am confused from where to start. It would be helpful if someone could guide from where to start. autosar MATLAB Answers — New Questions
Avoid Copies of Arrays in MEX Functions
My question is about following example which can be found in documentation:
#include "mex.hpp"
#include "mexAdapter.hpp"
using namespace matlab::data;
using matlab::mex::ArgumentList;
class MexFunction : public matlab::mex::Function {
ArrayFactory factory;
public:
void operator()(ArgumentList outputs, ArgumentList inputs) {
double sm = 0;
const TypedArray<double> inArray = inputs[0];
for (auto& elem : inArray) {
sm += elem;
}
outputs[0] = factory.createScalar(sm);
}
};
How important is to use the keyword "const" in declaration of inArray ? Will there be performance difference if I omit it ? I use following function in MEX module which is called from MexFunction::operator():
void Initialize(TypedArray<double> x, TypedArray<double> y)
{
…
}
void operator()(ArgumentList outputs, ArgumentList inputs)
{
…
Initialize(inputs[1], inputs[2])
…
}
Should I declare the input arguments of Initialize function as const to improve performance ? Problem is that code can be compiled and run without problems but I don’t know what happens under the hood. If possible I want to avoid uneccessary allocations and deallocations. Especially if it is that simple like adding one keyword. In other projects unrelated to MATLAB i use references or pointers where possible if the underlying data type is complex. What is preferred way to pass data in MEX modules ?My question is about following example which can be found in documentation:
#include "mex.hpp"
#include "mexAdapter.hpp"
using namespace matlab::data;
using matlab::mex::ArgumentList;
class MexFunction : public matlab::mex::Function {
ArrayFactory factory;
public:
void operator()(ArgumentList outputs, ArgumentList inputs) {
double sm = 0;
const TypedArray<double> inArray = inputs[0];
for (auto& elem : inArray) {
sm += elem;
}
outputs[0] = factory.createScalar(sm);
}
};
How important is to use the keyword "const" in declaration of inArray ? Will there be performance difference if I omit it ? I use following function in MEX module which is called from MexFunction::operator():
void Initialize(TypedArray<double> x, TypedArray<double> y)
{
…
}
void operator()(ArgumentList outputs, ArgumentList inputs)
{
…
Initialize(inputs[1], inputs[2])
…
}
Should I declare the input arguments of Initialize function as const to improve performance ? Problem is that code can be compiled and run without problems but I don’t know what happens under the hood. If possible I want to avoid uneccessary allocations and deallocations. Especially if it is that simple like adding one keyword. In other projects unrelated to MATLAB i use references or pointers where possible if the underlying data type is complex. What is preferred way to pass data in MEX modules ? My question is about following example which can be found in documentation:
#include "mex.hpp"
#include "mexAdapter.hpp"
using namespace matlab::data;
using matlab::mex::ArgumentList;
class MexFunction : public matlab::mex::Function {
ArrayFactory factory;
public:
void operator()(ArgumentList outputs, ArgumentList inputs) {
double sm = 0;
const TypedArray<double> inArray = inputs[0];
for (auto& elem : inArray) {
sm += elem;
}
outputs[0] = factory.createScalar(sm);
}
};
How important is to use the keyword "const" in declaration of inArray ? Will there be performance difference if I omit it ? I use following function in MEX module which is called from MexFunction::operator():
void Initialize(TypedArray<double> x, TypedArray<double> y)
{
…
}
void operator()(ArgumentList outputs, ArgumentList inputs)
{
…
Initialize(inputs[1], inputs[2])
…
}
Should I declare the input arguments of Initialize function as const to improve performance ? Problem is that code can be compiled and run without problems but I don’t know what happens under the hood. If possible I want to avoid uneccessary allocations and deallocations. Especially if it is that simple like adding one keyword. In other projects unrelated to MATLAB i use references or pointers where possible if the underlying data type is complex. What is preferred way to pass data in MEX modules ? mex, performance, c++ MATLAB Answers — New Questions
How to get a graph of an equation having a sigma notation with double indices
How to write a code with for loop to get a graph of the following equation?
.How to write a code with for loop to get a graph of the following equation?
. How to write a code with for loop to get a graph of the following equation?
. sigma with double indices MATLAB Answers — New Questions
What should be the sample time of the input pin to read the PWM signals?
I used a Arduino Mega to generate PWM pulses with varying duty cycles and frequency 100Hz.
This is the following output on a external logic analyzer connected to the 3, 5 pins. It shows a duty cycle of 20%
I configured an ESP32 WROOM(30 pin) to read the same PWM input using the digital pins with sample time = 0.005. I’m not getting the same input as expected.
Also the PWM inputs appear discontinuous in the simulink logic analyzer
What frequency should I configure such that I get the same input PWM as in the external logic analyzer?I used a Arduino Mega to generate PWM pulses with varying duty cycles and frequency 100Hz.
This is the following output on a external logic analyzer connected to the 3, 5 pins. It shows a duty cycle of 20%
I configured an ESP32 WROOM(30 pin) to read the same PWM input using the digital pins with sample time = 0.005. I’m not getting the same input as expected.
Also the PWM inputs appear discontinuous in the simulink logic analyzer
What frequency should I configure such that I get the same input PWM as in the external logic analyzer? I used a Arduino Mega to generate PWM pulses with varying duty cycles and frequency 100Hz.
This is the following output on a external logic analyzer connected to the 3, 5 pins. It shows a duty cycle of 20%
I configured an ESP32 WROOM(30 pin) to read the same PWM input using the digital pins with sample time = 0.005. I’m not getting the same input as expected.
Also the PWM inputs appear discontinuous in the simulink logic analyzer
What frequency should I configure such that I get the same input PWM as in the external logic analyzer? arduino, pwm, simulink, electric_motor_control, input, esp32, output MATLAB Answers — New Questions
error with ‘syms’
Hello
I have a problem with use ‘syms’ function
I want to execute the code below
—————————–
syms x y
f=x^2+y
__________________
but the error message ‘Execute script syms as a function is not supported’
I have installed the symbolic toolbox. How can i execute the code??
thanks a lotHello
I have a problem with use ‘syms’ function
I want to execute the code below
—————————–
syms x y
f=x^2+y
__________________
but the error message ‘Execute script syms as a function is not supported’
I have installed the symbolic toolbox. How can i execute the code??
thanks a lot Hello
I have a problem with use ‘syms’ function
I want to execute the code below
—————————–
syms x y
f=x^2+y
__________________
but the error message ‘Execute script syms as a function is not supported’
I have installed the symbolic toolbox. How can i execute the code??
thanks a lot syms MATLAB Answers — New Questions