Category: Matlab
Category Archives: Matlab
Vertical blank space in tiledlayout compact
Dear all
I am plotting the following:
u1=figure(‘visible’,’off’,’units’,’pixels’,’position’,[0 0 1920 1080]);
t=tiledlayout(2,2,’Padding’,’compact’);
title(t,[‘Bilayer. Monte Carlo, $15$ million steps. $T=2$ K, $mathbf{H}=0$’;”;”],’FontSize’,18,’interpreter’,’latex’);
ax1=nexttile;
uimagesc(space_x,space_y,mx);
axis xy;
clim([-round(max([abs(max(max(mx))) abs(min(min(mx)))]),2) round(max([abs(max(max(mx))) abs(min(min(mx)))]),2)]);
colormap(ax1,bluewhitered(256));
box on;
clr1=colorbar(‘YTick’,[-round(max([abs(max(max(mx))) abs(min(min(mx)))]),2) -round(max([abs(max(max(mx))) abs(min(min(mx)))])/2,2) 0 round(max([abs(max(max(mx))) abs(min(min(mx)))])/2,2) round(max([abs(max(max(mx))) abs(min(min(mx)))]),2)]);
set(clr1,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr1,’$a$-{it th} magnetization component, $m_a$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax2=nexttile;
uimagesc(space_x,space_y,my);
clim([-max([abs(max(max(my))) abs(min(min(my)))]) max([abs(max(max(my))) abs(min(min(my)))])]);
colormap(ax2,bluewhitered(256));
axis xy;
box on;
clr2=colorbar(‘YTick’,[-max([abs(max(max(my))) abs(min(min(my)))]) -max([abs(max(max(my))) abs(min(min(my)))])/2 0 max([abs(max(max(my))) abs(min(min(my)))])/2 max([abs(max(max(my))) abs(min(min(my)))])]);
set(clr2,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr2,’$b$-{it th} magnetization component, $m_b$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax3=nexttile;
uimagesc(space_x,space_y,mz);
box on;
axis xy;
clim([-max([abs(max(max(mz))) abs(min(min(mz)))]) max([abs(max(max(mz))) abs(min(min(mz)))])]);
colormap(ax3,bluewhitered(256));
clr3=colorbar(‘YTick’,[-max([abs(max(max(mz))) abs(min(min(mz)))]) -max([abs(max(max(mz))) abs(min(min(mz)))])/2 0 max([abs(max(max(mz))) abs(min(min(mz)))])/2 max([abs(max(max(mz))) abs(min(min(mz)))])]);
set(clr3,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr3,’$z$-{it th} magnetization component, $m_z$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax4=nexttile;
uimagesc(space_x,space_y,total_magnetization);
box on;
axis xy;
clim([0 max(max(total_magnetization))]);
colormap(ax4,cmap);
clr4=colorbar(‘YTick’,[0 max(max(total_magnetization))/5 2*max(max(total_magnetization))/5 3*max(max(total_magnetization))/5 4*max(max(total_magnetization))/5 max(max(total_magnetization))]);
set(clr4,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr4,’Magnetization vector modulus, $left| mathbf{m} right|$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
set(gcf,’color’,’white’);
set(gca,’Units’,’normalized’);
set(u1,’Units’,’Inches’);
posu1=get(u1,’Position’);
set(u1,’PaperPositionMode’,’Auto’,’PaperUnits’,’Inches’,’PaperSize’,[posu1(3),posu1(4)]);
and the plot looks like:
As you can see there is some vertical unnecessary space between the two horizontal stacks of plots. I would like to reduce it to be able to put the general title "Bilayer…" far enough from the top plots.
Any ideas?Dear all
I am plotting the following:
u1=figure(‘visible’,’off’,’units’,’pixels’,’position’,[0 0 1920 1080]);
t=tiledlayout(2,2,’Padding’,’compact’);
title(t,[‘Bilayer. Monte Carlo, $15$ million steps. $T=2$ K, $mathbf{H}=0$’;”;”],’FontSize’,18,’interpreter’,’latex’);
ax1=nexttile;
uimagesc(space_x,space_y,mx);
axis xy;
clim([-round(max([abs(max(max(mx))) abs(min(min(mx)))]),2) round(max([abs(max(max(mx))) abs(min(min(mx)))]),2)]);
colormap(ax1,bluewhitered(256));
box on;
clr1=colorbar(‘YTick’,[-round(max([abs(max(max(mx))) abs(min(min(mx)))]),2) -round(max([abs(max(max(mx))) abs(min(min(mx)))])/2,2) 0 round(max([abs(max(max(mx))) abs(min(min(mx)))])/2,2) round(max([abs(max(max(mx))) abs(min(min(mx)))]),2)]);
set(clr1,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr1,’$a$-{it th} magnetization component, $m_a$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax2=nexttile;
uimagesc(space_x,space_y,my);
clim([-max([abs(max(max(my))) abs(min(min(my)))]) max([abs(max(max(my))) abs(min(min(my)))])]);
colormap(ax2,bluewhitered(256));
axis xy;
box on;
clr2=colorbar(‘YTick’,[-max([abs(max(max(my))) abs(min(min(my)))]) -max([abs(max(max(my))) abs(min(min(my)))])/2 0 max([abs(max(max(my))) abs(min(min(my)))])/2 max([abs(max(max(my))) abs(min(min(my)))])]);
set(clr2,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr2,’$b$-{it th} magnetization component, $m_b$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax3=nexttile;
uimagesc(space_x,space_y,mz);
box on;
axis xy;
clim([-max([abs(max(max(mz))) abs(min(min(mz)))]) max([abs(max(max(mz))) abs(min(min(mz)))])]);
colormap(ax3,bluewhitered(256));
clr3=colorbar(‘YTick’,[-max([abs(max(max(mz))) abs(min(min(mz)))]) -max([abs(max(max(mz))) abs(min(min(mz)))])/2 0 max([abs(max(max(mz))) abs(min(min(mz)))])/2 max([abs(max(max(mz))) abs(min(min(mz)))])]);
set(clr3,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr3,’$z$-{it th} magnetization component, $m_z$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax4=nexttile;
uimagesc(space_x,space_y,total_magnetization);
box on;
axis xy;
clim([0 max(max(total_magnetization))]);
colormap(ax4,cmap);
clr4=colorbar(‘YTick’,[0 max(max(total_magnetization))/5 2*max(max(total_magnetization))/5 3*max(max(total_magnetization))/5 4*max(max(total_magnetization))/5 max(max(total_magnetization))]);
set(clr4,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr4,’Magnetization vector modulus, $left| mathbf{m} right|$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
set(gcf,’color’,’white’);
set(gca,’Units’,’normalized’);
set(u1,’Units’,’Inches’);
posu1=get(u1,’Position’);
set(u1,’PaperPositionMode’,’Auto’,’PaperUnits’,’Inches’,’PaperSize’,[posu1(3),posu1(4)]);
and the plot looks like:
As you can see there is some vertical unnecessary space between the two horizontal stacks of plots. I would like to reduce it to be able to put the general title "Bilayer…" far enough from the top plots.
Any ideas? Dear all
I am plotting the following:
u1=figure(‘visible’,’off’,’units’,’pixels’,’position’,[0 0 1920 1080]);
t=tiledlayout(2,2,’Padding’,’compact’);
title(t,[‘Bilayer. Monte Carlo, $15$ million steps. $T=2$ K, $mathbf{H}=0$’;”;”],’FontSize’,18,’interpreter’,’latex’);
ax1=nexttile;
uimagesc(space_x,space_y,mx);
axis xy;
clim([-round(max([abs(max(max(mx))) abs(min(min(mx)))]),2) round(max([abs(max(max(mx))) abs(min(min(mx)))]),2)]);
colormap(ax1,bluewhitered(256));
box on;
clr1=colorbar(‘YTick’,[-round(max([abs(max(max(mx))) abs(min(min(mx)))]),2) -round(max([abs(max(max(mx))) abs(min(min(mx)))])/2,2) 0 round(max([abs(max(max(mx))) abs(min(min(mx)))])/2,2) round(max([abs(max(max(mx))) abs(min(min(mx)))]),2)]);
set(clr1,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr1,’$a$-{it th} magnetization component, $m_a$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax2=nexttile;
uimagesc(space_x,space_y,my);
clim([-max([abs(max(max(my))) abs(min(min(my)))]) max([abs(max(max(my))) abs(min(min(my)))])]);
colormap(ax2,bluewhitered(256));
axis xy;
box on;
clr2=colorbar(‘YTick’,[-max([abs(max(max(my))) abs(min(min(my)))]) -max([abs(max(max(my))) abs(min(min(my)))])/2 0 max([abs(max(max(my))) abs(min(min(my)))])/2 max([abs(max(max(my))) abs(min(min(my)))])]);
set(clr2,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr2,’$b$-{it th} magnetization component, $m_b$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax3=nexttile;
uimagesc(space_x,space_y,mz);
box on;
axis xy;
clim([-max([abs(max(max(mz))) abs(min(min(mz)))]) max([abs(max(max(mz))) abs(min(min(mz)))])]);
colormap(ax3,bluewhitered(256));
clr3=colorbar(‘YTick’,[-max([abs(max(max(mz))) abs(min(min(mz)))]) -max([abs(max(max(mz))) abs(min(min(mz)))])/2 0 max([abs(max(max(mz))) abs(min(min(mz)))])/2 max([abs(max(max(mz))) abs(min(min(mz)))])]);
set(clr3,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr3,’$z$-{it th} magnetization component, $m_z$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
ax4=nexttile;
uimagesc(space_x,space_y,total_magnetization);
box on;
axis xy;
clim([0 max(max(total_magnetization))]);
colormap(ax4,cmap);
clr4=colorbar(‘YTick’,[0 max(max(total_magnetization))/5 2*max(max(total_magnetization))/5 3*max(max(total_magnetization))/5 4*max(max(total_magnetization))/5 max(max(total_magnetization))]);
set(clr4,’TickLabelInterpreter’,’latex’);
xlabel(‘$a$-{it th} spatial direction, $a , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(‘$b$-{it th} spatial direction, $b , , left( mathrm{nm} right)$’,’FontSize’,15,’interpreter’,’latex’);
ylabel(clr4,’Magnetization vector modulus, $left| mathbf{m} right|$’,’Interpreter’,’Latex’,’FontSize’,16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,15);
set(gcf,’color’,’white’);
set(gca,’Units’,’normalized’);
set(u1,’Units’,’Inches’);
posu1=get(u1,’Position’);
set(u1,’PaperPositionMode’,’Auto’,’PaperUnits’,’Inches’,’PaperSize’,[posu1(3),posu1(4)]);
and the plot looks like:
As you can see there is some vertical unnecessary space between the two horizontal stacks of plots. I would like to reduce it to be able to put the general title "Bilayer…" far enough from the top plots.
Any ideas? padding compact tiledlayout MATLAB Answers — New Questions
How can I install MATLAB without the default JRE?
I noticed that MATLAB does not ship with the newest version of the Java Runtime Environment.Can I install a newer JRE and configure MATLAB to use it?I noticed that MATLAB does not ship with the newest version of the Java Runtime Environment.Can I install a newer JRE and configure MATLAB to use it? I noticed that MATLAB does not ship with the newest version of the Java Runtime Environment.Can I install a newer JRE and configure MATLAB to use it? MATLAB Answers — New Questions
Untraining the SalsaNext model Architecture
I used the following repository to evaluate my data (https://github.com/matlab-deep-learning/pretrained-salsanext), but it loads a pretrained SalsaNext model. I would like to know whether it is possible to untrain the model, or to train it from scratch without creating the layergraph (Since this model involves a large number of layers, and the work seems to be cumbersome, and error-prone).
ThanksI used the following repository to evaluate my data (https://github.com/matlab-deep-learning/pretrained-salsanext), but it loads a pretrained SalsaNext model. I would like to know whether it is possible to untrain the model, or to train it from scratch without creating the layergraph (Since this model involves a large number of layers, and the work seems to be cumbersome, and error-prone).
Thanks I used the following repository to evaluate my data (https://github.com/matlab-deep-learning/pretrained-salsanext), but it loads a pretrained SalsaNext model. I would like to know whether it is possible to untrain the model, or to train it from scratch without creating the layergraph (Since this model involves a large number of layers, and the work seems to be cumbersome, and error-prone).
Thanks salsanext, untraining, neural network MATLAB Answers — New Questions
Designing fuzzy inference system and subsystems
Hello.I have several fuzzy systems about security, all of which have 3 outputs: weak, medium and strong. In the comprehensive system, I want to enter all these fuzzy systems and in addition ask it to calculate if it sees 10 weak cases, the final output will be the vulnerable level. Is this possible? Can you guide me?Hello.I have several fuzzy systems about security, all of which have 3 outputs: weak, medium and strong. In the comprehensive system, I want to enter all these fuzzy systems and in addition ask it to calculate if it sees 10 weak cases, the final output will be the vulnerable level. Is this possible? Can you guide me? Hello.I have several fuzzy systems about security, all of which have 3 outputs: weak, medium and strong. In the comprehensive system, I want to enter all these fuzzy systems and in addition ask it to calculate if it sees 10 weak cases, the final output will be the vulnerable level. Is this possible? Can you guide me? fuzzy inference system, fuzzy MATLAB Answers — New Questions
“Does the rotor core of the Synchronous Machine Model 1.0 include hysteresis characteristics?”
I am using the Synchronous Machine Model 1.0 in Simulink Simscape.
Does the rotor core of the Synchronous Machine Model 1.0 include hysteresis characteristics?I am using the Synchronous Machine Model 1.0 in Simulink Simscape.
Does the rotor core of the Synchronous Machine Model 1.0 include hysteresis characteristics? I am using the Synchronous Machine Model 1.0 in Simulink Simscape.
Does the rotor core of the Synchronous Machine Model 1.0 include hysteresis characteristics? simulink, simscape, electric_motor_control, model MATLAB Answers — New Questions
Problem with single agent Simulink using RL toolbox
I am using RL toolbox to train a single agent with the following specifications:
for type=1
% obsMat = [1 1];
obsMat = [4 3; 5 3; 6 3; 7 3; 8 3; 9 3; 5 11; 6 11; 7 11; 8 11; 6 12; 7 12; 3 12; ];
% obsMat = [ ];
sA0 = [2 5];
switch type
case 1
s0 = [sA0];
end
Ts = 0.1;
Tf = 100;
maxsteps = ceil(Tf/Ts);
switch type
case 1
mdl = "rlAreaCoverage1";
end
open_system(mdl)
% Define observation specifications.
obsSize = [12 12 4];
oinfo = rlNumericSpec(obsSize);
oinfo.Name = "observations";
% Define action specifications.
numAct=131
switch numAct
case 131
actionSpace = {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 129 130 131 132 133 134 136 137 140 141 142 143 144};
end
ainfo = rlFiniteSetSpec(actionSpace);
ainfo.Name = "actions";
switch type
case 1
blks = mdl + ["/Agent A (Red)"];
end
switch type
case 1
env = rlSimulinkEnv(mdl,blks,{oinfo},{ainfo});
end
env.ResetFcn = @(in) resetMap(in, obsMat);
rng(0)
but I see this error:
Error using rlSimulinkEnv>localValidateIOSpecs (line 178)
Invalid size or type for observation specification.
Error in rlSimulinkEnv (line 90)
localValidateIOSpecs(numAgents,observationInfo,actionInfo);
Do you have any idea what is wrong in my setup?I am using RL toolbox to train a single agent with the following specifications:
for type=1
% obsMat = [1 1];
obsMat = [4 3; 5 3; 6 3; 7 3; 8 3; 9 3; 5 11; 6 11; 7 11; 8 11; 6 12; 7 12; 3 12; ];
% obsMat = [ ];
sA0 = [2 5];
switch type
case 1
s0 = [sA0];
end
Ts = 0.1;
Tf = 100;
maxsteps = ceil(Tf/Ts);
switch type
case 1
mdl = "rlAreaCoverage1";
end
open_system(mdl)
% Define observation specifications.
obsSize = [12 12 4];
oinfo = rlNumericSpec(obsSize);
oinfo.Name = "observations";
% Define action specifications.
numAct=131
switch numAct
case 131
actionSpace = {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 129 130 131 132 133 134 136 137 140 141 142 143 144};
end
ainfo = rlFiniteSetSpec(actionSpace);
ainfo.Name = "actions";
switch type
case 1
blks = mdl + ["/Agent A (Red)"];
end
switch type
case 1
env = rlSimulinkEnv(mdl,blks,{oinfo},{ainfo});
end
env.ResetFcn = @(in) resetMap(in, obsMat);
rng(0)
but I see this error:
Error using rlSimulinkEnv>localValidateIOSpecs (line 178)
Invalid size or type for observation specification.
Error in rlSimulinkEnv (line 90)
localValidateIOSpecs(numAgents,observationInfo,actionInfo);
Do you have any idea what is wrong in my setup? I am using RL toolbox to train a single agent with the following specifications:
for type=1
% obsMat = [1 1];
obsMat = [4 3; 5 3; 6 3; 7 3; 8 3; 9 3; 5 11; 6 11; 7 11; 8 11; 6 12; 7 12; 3 12; ];
% obsMat = [ ];
sA0 = [2 5];
switch type
case 1
s0 = [sA0];
end
Ts = 0.1;
Tf = 100;
maxsteps = ceil(Tf/Ts);
switch type
case 1
mdl = "rlAreaCoverage1";
end
open_system(mdl)
% Define observation specifications.
obsSize = [12 12 4];
oinfo = rlNumericSpec(obsSize);
oinfo.Name = "observations";
% Define action specifications.
numAct=131
switch numAct
case 131
actionSpace = {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 129 130 131 132 133 134 136 137 140 141 142 143 144};
end
ainfo = rlFiniteSetSpec(actionSpace);
ainfo.Name = "actions";
switch type
case 1
blks = mdl + ["/Agent A (Red)"];
end
switch type
case 1
env = rlSimulinkEnv(mdl,blks,{oinfo},{ainfo});
end
env.ResetFcn = @(in) resetMap(in, obsMat);
rng(0)
but I see this error:
Error using rlSimulinkEnv>localValidateIOSpecs (line 178)
Invalid size or type for observation specification.
Error in rlSimulinkEnv (line 90)
localValidateIOSpecs(numAgents,observationInfo,actionInfo);
Do you have any idea what is wrong in my setup? reinforcement learning MATLAB Answers — New Questions
I want to plot the auto correlation function for 15 numbers without using the inbuilt function. My series is P=[ 47,64,23,71,38,64,55,41,59,48,71,35,57,40,58 ] and the plot should be autocorrelation function vs lags.
I want to plot the auto correlation function for 15 numbers without using the inbuilt function.
My code is as follows:
P=[ 47,64,23,71,38,64,55,41,59,48]; %%,71,35,57,40,58 ];
N=length(P);
Q=P(1:N);
R=P(1:N);
N1=length(Q);
N2=length(R);
u=mean(P);
sum= ((Q-u)*(R-u).’);
covar0=sum/N1;
for k=1:N-1 %% k is no. of lags and its max value can be 14 here
Q1=P(1:N-k); %% Splitting the series into 2 series separated by lag k
R1=P(1+k:N);
N1_1=length(Q1);
N2_1=length(R1);
sum1= ((Q1-u)*(R1-u).’);
covark=sum1/N;
acf=covark/covar0;
acf;
end
But after execution of the loop,I am getting acf value only for last value of k, which rather should have been an array for values of k=1 to 14.
I am new to matlab. Plz help me resolve the code.I want to plot the auto correlation function for 15 numbers without using the inbuilt function.
My code is as follows:
P=[ 47,64,23,71,38,64,55,41,59,48]; %%,71,35,57,40,58 ];
N=length(P);
Q=P(1:N);
R=P(1:N);
N1=length(Q);
N2=length(R);
u=mean(P);
sum= ((Q-u)*(R-u).’);
covar0=sum/N1;
for k=1:N-1 %% k is no. of lags and its max value can be 14 here
Q1=P(1:N-k); %% Splitting the series into 2 series separated by lag k
R1=P(1+k:N);
N1_1=length(Q1);
N2_1=length(R1);
sum1= ((Q1-u)*(R1-u).’);
covark=sum1/N;
acf=covark/covar0;
acf;
end
But after execution of the loop,I am getting acf value only for last value of k, which rather should have been an array for values of k=1 to 14.
I am new to matlab. Plz help me resolve the code. I want to plot the auto correlation function for 15 numbers without using the inbuilt function.
My code is as follows:
P=[ 47,64,23,71,38,64,55,41,59,48]; %%,71,35,57,40,58 ];
N=length(P);
Q=P(1:N);
R=P(1:N);
N1=length(Q);
N2=length(R);
u=mean(P);
sum= ((Q-u)*(R-u).’);
covar0=sum/N1;
for k=1:N-1 %% k is no. of lags and its max value can be 14 here
Q1=P(1:N-k); %% Splitting the series into 2 series separated by lag k
R1=P(1+k:N);
N1_1=length(Q1);
N2_1=length(R1);
sum1= ((Q1-u)*(R1-u).’);
covark=sum1/N;
acf=covark/covar0;
acf;
end
But after execution of the loop,I am getting acf value only for last value of k, which rather should have been an array for values of k=1 to 14.
I am new to matlab. Plz help me resolve the code. auto correlation, for loop MATLAB Answers — New Questions
Different filters for pretrainned network
if i have a group of images and i filtered all of them with 8 different filters , is there a way or method or a published something or calculate a fator to know me which filtered group is best with specific pretrainned transfer learning network for classification task using matlab without training the network with each group of filtered imagesif i have a group of images and i filtered all of them with 8 different filters , is there a way or method or a published something or calculate a fator to know me which filtered group is best with specific pretrainned transfer learning network for classification task using matlab without training the network with each group of filtered images if i have a group of images and i filtered all of them with 8 different filters , is there a way or method or a published something or calculate a fator to know me which filtered group is best with specific pretrainned transfer learning network for classification task using matlab without training the network with each group of filtered images filtering pretrainned MATLAB Answers — New Questions
How to display Chart diagram in a report, using report generator?
Hi,
I have a problem with the visualization of Chart diagram and related properties in my model.
I using this code line (in a matlab script) to search all the subsystem object (including chart):
allsubsysObj = modelObj.find(‘-isa’,’Simulink.SubSystem’,’-or’,’-isa’,’Simulink.ModelReference’,’-depth’,1);
The script find the number of element that i’m expected (2 chart and 2 subsytem) but when i tried to put the diagram figure i obtained the inner content of the subsytem and the chart.
auxpara = CenterDiagram(Diagram(allsubsysObj(1)),R);
Cap = Text(strcat("Figure ",num2str(ChCounter),".",num2str(FigCounter),": ",allsubsysObj(1).Name," subsystem"));
Cap.Style = [{FontSize(Str.CapFontSize)},{Color(Str.CapColor)},{Bold(true)},{HAlign(Str.CapAlign)}];
FigCounter = FigCounter + 1;
subsec.add(auxpara);
subsec.add(Cap);
subsec.add(LineBreak());
How i can insert only the top level diagram of the chart?Hi,
I have a problem with the visualization of Chart diagram and related properties in my model.
I using this code line (in a matlab script) to search all the subsystem object (including chart):
allsubsysObj = modelObj.find(‘-isa’,’Simulink.SubSystem’,’-or’,’-isa’,’Simulink.ModelReference’,’-depth’,1);
The script find the number of element that i’m expected (2 chart and 2 subsytem) but when i tried to put the diagram figure i obtained the inner content of the subsytem and the chart.
auxpara = CenterDiagram(Diagram(allsubsysObj(1)),R);
Cap = Text(strcat("Figure ",num2str(ChCounter),".",num2str(FigCounter),": ",allsubsysObj(1).Name," subsystem"));
Cap.Style = [{FontSize(Str.CapFontSize)},{Color(Str.CapColor)},{Bold(true)},{HAlign(Str.CapAlign)}];
FigCounter = FigCounter + 1;
subsec.add(auxpara);
subsec.add(Cap);
subsec.add(LineBreak());
How i can insert only the top level diagram of the chart? Hi,
I have a problem with the visualization of Chart diagram and related properties in my model.
I using this code line (in a matlab script) to search all the subsystem object (including chart):
allsubsysObj = modelObj.find(‘-isa’,’Simulink.SubSystem’,’-or’,’-isa’,’Simulink.ModelReference’,’-depth’,1);
The script find the number of element that i’m expected (2 chart and 2 subsytem) but when i tried to put the diagram figure i obtained the inner content of the subsytem and the chart.
auxpara = CenterDiagram(Diagram(allsubsysObj(1)),R);
Cap = Text(strcat("Figure ",num2str(ChCounter),".",num2str(FigCounter),": ",allsubsysObj(1).Name," subsystem"));
Cap.Style = [{FontSize(Str.CapFontSize)},{Color(Str.CapColor)},{Bold(true)},{HAlign(Str.CapAlign)}];
FigCounter = FigCounter + 1;
subsec.add(auxpara);
subsec.add(Cap);
subsec.add(LineBreak());
How i can insert only the top level diagram of the chart? report generation MATLAB Answers — New Questions
sinad() function verification problems
Hi, I am doing DSP with sinad() function.
I wonder :
1.How sinad() verify the "wanted signal" and how is the notch filter decided?
It seems that if I put some different 1k audio raw datas into sinad(), it has different notch bandwidth
2. sinad() use a periodogram and kaiser window with beta=38, how is this decided?Hi, I am doing DSP with sinad() function.
I wonder :
1.How sinad() verify the "wanted signal" and how is the notch filter decided?
It seems that if I put some different 1k audio raw datas into sinad(), it has different notch bandwidth
2. sinad() use a periodogram and kaiser window with beta=38, how is this decided? Hi, I am doing DSP with sinad() function.
I wonder :
1.How sinad() verify the "wanted signal" and how is the notch filter decided?
It seems that if I put some different 1k audio raw datas into sinad(), it has different notch bandwidth
2. sinad() use a periodogram and kaiser window with beta=38, how is this decided? sinad, dsp, fft, periodogram MATLAB Answers — New Questions
Matlab HDL cosimulation for Lattice CPLD
I regularly develop VHDL code for controllers that is supposed to run on FPGAs/CPLDs and I’m looking for possibilities to co-simulate this code in a closed-loop simulation environment that mimics the behavior of the controlled system. So what I would like to have is that I can define a dyamic model in Matlab (e.g., as a state-space model or a transfer function) and to simulate this model together with the controller’s HDL implementation using the outputs of the models as stimuli for the controller and the output of the controller as input for the dynamic model. Is there any way I can accomplish this with Matlab? If so, what do I have to look for?
What I found so far is apparently called HDL verifier and seems to be pretty much what I want. However, I’m currently using Lattice MachXO2 CPLDs and Lattice diamond comes with "ModelSim Lattice FPGA Edition" as a simulator. According to this post
https://ch.mathworks.com/matlabcentral/answers/493504-which-modelsim-editions-can-i-use-for-cosimulation-with-hdl-verifier
HDL verifier requires a FLI (foreign language interface), which the Lattice Edition of ModelSim does not provide. Is there any way I can use HDL verifier, e.g., by using a different simulator?I regularly develop VHDL code for controllers that is supposed to run on FPGAs/CPLDs and I’m looking for possibilities to co-simulate this code in a closed-loop simulation environment that mimics the behavior of the controlled system. So what I would like to have is that I can define a dyamic model in Matlab (e.g., as a state-space model or a transfer function) and to simulate this model together with the controller’s HDL implementation using the outputs of the models as stimuli for the controller and the output of the controller as input for the dynamic model. Is there any way I can accomplish this with Matlab? If so, what do I have to look for?
What I found so far is apparently called HDL verifier and seems to be pretty much what I want. However, I’m currently using Lattice MachXO2 CPLDs and Lattice diamond comes with "ModelSim Lattice FPGA Edition" as a simulator. According to this post
https://ch.mathworks.com/matlabcentral/answers/493504-which-modelsim-editions-can-i-use-for-cosimulation-with-hdl-verifier
HDL verifier requires a FLI (foreign language interface), which the Lattice Edition of ModelSim does not provide. Is there any way I can use HDL verifier, e.g., by using a different simulator? I regularly develop VHDL code for controllers that is supposed to run on FPGAs/CPLDs and I’m looking for possibilities to co-simulate this code in a closed-loop simulation environment that mimics the behavior of the controlled system. So what I would like to have is that I can define a dyamic model in Matlab (e.g., as a state-space model or a transfer function) and to simulate this model together with the controller’s HDL implementation using the outputs of the models as stimuli for the controller and the output of the controller as input for the dynamic model. Is there any way I can accomplish this with Matlab? If so, what do I have to look for?
What I found so far is apparently called HDL verifier and seems to be pretty much what I want. However, I’m currently using Lattice MachXO2 CPLDs and Lattice diamond comes with "ModelSim Lattice FPGA Edition" as a simulator. According to this post
https://ch.mathworks.com/matlabcentral/answers/493504-which-modelsim-editions-can-i-use-for-cosimulation-with-hdl-verifier
HDL verifier requires a FLI (foreign language interface), which the Lattice Edition of ModelSim does not provide. Is there any way I can use HDL verifier, e.g., by using a different simulator? vhdl, hdl simulation, hdl verifier, cosimlation, fpga MATLAB Answers — New Questions
How to display a color bar in Matlab as shown below
Hello, experts.
I want to draw a color bar with discontinuous and regular intervals like the first picture above.
However, it would be best to draw a continuous color bar like the second picture. Is there a solution?Hello, experts.
I want to draw a color bar with discontinuous and regular intervals like the first picture above.
However, it would be best to draw a continuous color bar like the second picture. Is there a solution? Hello, experts.
I want to draw a color bar with discontinuous and regular intervals like the first picture above.
However, it would be best to draw a continuous color bar like the second picture. Is there a solution? colorbar, colormap, colormapeditor MATLAB Answers — New Questions
How to train Unet semantic segmentation with only one single class/label?
Hello, I’m currently working on a task to do a semantic segmentation on USG image to locate TMJ. I did my image labelling in Image Labeler App and only did one class so that the class region will be 1 and background is 0. I was about to train my model with unetLayers but it says "The value of ‘numClasses’ is invalid. Expected numClasses to be a scalar with value > 1."
I’m aware that someone asked this similar question here with an answer, but I want to ask, how to customize specifically unetLayers to accomodate single class? I see that unetLayers also has softmaxLayers but i can’t find the pixel layers. Thank you in advance!Hello, I’m currently working on a task to do a semantic segmentation on USG image to locate TMJ. I did my image labelling in Image Labeler App and only did one class so that the class region will be 1 and background is 0. I was about to train my model with unetLayers but it says "The value of ‘numClasses’ is invalid. Expected numClasses to be a scalar with value > 1."
I’m aware that someone asked this similar question here with an answer, but I want to ask, how to customize specifically unetLayers to accomodate single class? I see that unetLayers also has softmaxLayers but i can’t find the pixel layers. Thank you in advance! Hello, I’m currently working on a task to do a semantic segmentation on USG image to locate TMJ. I did my image labelling in Image Labeler App and only did one class so that the class region will be 1 and background is 0. I was about to train my model with unetLayers but it says "The value of ‘numClasses’ is invalid. Expected numClasses to be a scalar with value > 1."
I’m aware that someone asked this similar question here with an answer, but I want to ask, how to customize specifically unetLayers to accomodate single class? I see that unetLayers also has softmaxLayers but i can’t find the pixel layers. Thank you in advance! deep learning MATLAB Answers — New Questions
Troubleshooting Build Error in MAC Apple Silicon Processor for Simulink Support Package for Arduino Hardware
Build for any Target Hardware selected fails for MAC Apple Silicon Processor with the following error "bad CPU Type in executable".Build for any Target Hardware selected fails for MAC Apple Silicon Processor with the following error "bad CPU Type in executable". Build for any Target Hardware selected fails for MAC Apple Silicon Processor with the following error "bad CPU Type in executable". arduino, simulink, matlab, mac MATLAB Answers — New Questions
FFT of 3D array in MATLAB
I am trying to understand how the FFT of different directions in MATLAB works to reproduce in C/C++ instead.
So far I have the following simple example in MATLAB:
clearvars; clc; close all;
%3D FFT test
Nx = 8;
Ny = 4;
Nz= 6;
Lx =16;
Ly = 6;
dx = Lx/Nx;
dy = Ly/Ny;
%———–
xi_x = (2*pi)/Lx;
yi_y = (2*pi)/Ly;
xi = ((0:Nx-1)/Nx)*(2*pi);
yi = ((0:Ny-1)/Ny)*(2*pi);
x = xi/xi_x;
y = yi/yi_y;
zlow = 0; %a
zupp =6; %b
Lz = (zupp-zlow);
eta_zgl = 2/Lz;
[D,zgl] = cheb(Nz);
zgl = (1/2)*(((zupp-zlow)*zgl) + (zupp+zlow));
[X,Z,Y] = meshgrid(x,zgl,y); %this gives 3d grid with z-by-x-by-y size (i.e. ZXY)
%ICs
A = 2*pi / Lx;
B = 2*pi / Ly;
u = (Z-zlow) .* (Z-zupp) .* sin(A*X).* sin(B*Y);
uh1 =(fft(u,[],3));%ZXY
uh2 =(fft(u,[],1));%ZXY
uh3 =(fft(u,[],2));%ZXY
So, in C/C++ I have a 3D tensor with (Nz+1) rows and Nx coumns and Ny matrices and taking the 1D FFT along each "row" of u returns the same results as the following in MATLAB:
uh3 =(fft(u,[],2));%ZXY
While taking the 1D FFT of u along each column of u in C/C++ returns the same result as the following in MATLAB:
uh2 =(fft(u,[],1));%ZXY
Then my question is what does this 1D FFT represent? and how should I represent it in C/C++?
uh1 =(fft(u,[],3));%ZXY
The cheb(N) function is:
function [ D, x ] = cheb ( N )
if ( N == 0 )
D = 0.0;
x = 1.0;
return
end
x = cos ( pi * ( 0 : N ) / N )’;
c = [ 2.0; ones(N-1,1); 2.0 ] .* (-1.0).^(0:N)’;
X = repmat ( x, 1, N + 1 );
dX = X – X’;
% Set the off diagonal entries.
D =( c * (1.0 ./ c )’ ) ./ ( dX + ( eye ( N + 1 ) ) );
% Diagonal entries.
D = D – diag ( sum ( D’ ) );
return
endI am trying to understand how the FFT of different directions in MATLAB works to reproduce in C/C++ instead.
So far I have the following simple example in MATLAB:
clearvars; clc; close all;
%3D FFT test
Nx = 8;
Ny = 4;
Nz= 6;
Lx =16;
Ly = 6;
dx = Lx/Nx;
dy = Ly/Ny;
%———–
xi_x = (2*pi)/Lx;
yi_y = (2*pi)/Ly;
xi = ((0:Nx-1)/Nx)*(2*pi);
yi = ((0:Ny-1)/Ny)*(2*pi);
x = xi/xi_x;
y = yi/yi_y;
zlow = 0; %a
zupp =6; %b
Lz = (zupp-zlow);
eta_zgl = 2/Lz;
[D,zgl] = cheb(Nz);
zgl = (1/2)*(((zupp-zlow)*zgl) + (zupp+zlow));
[X,Z,Y] = meshgrid(x,zgl,y); %this gives 3d grid with z-by-x-by-y size (i.e. ZXY)
%ICs
A = 2*pi / Lx;
B = 2*pi / Ly;
u = (Z-zlow) .* (Z-zupp) .* sin(A*X).* sin(B*Y);
uh1 =(fft(u,[],3));%ZXY
uh2 =(fft(u,[],1));%ZXY
uh3 =(fft(u,[],2));%ZXY
So, in C/C++ I have a 3D tensor with (Nz+1) rows and Nx coumns and Ny matrices and taking the 1D FFT along each "row" of u returns the same results as the following in MATLAB:
uh3 =(fft(u,[],2));%ZXY
While taking the 1D FFT of u along each column of u in C/C++ returns the same result as the following in MATLAB:
uh2 =(fft(u,[],1));%ZXY
Then my question is what does this 1D FFT represent? and how should I represent it in C/C++?
uh1 =(fft(u,[],3));%ZXY
The cheb(N) function is:
function [ D, x ] = cheb ( N )
if ( N == 0 )
D = 0.0;
x = 1.0;
return
end
x = cos ( pi * ( 0 : N ) / N )’;
c = [ 2.0; ones(N-1,1); 2.0 ] .* (-1.0).^(0:N)’;
X = repmat ( x, 1, N + 1 );
dX = X – X’;
% Set the off diagonal entries.
D =( c * (1.0 ./ c )’ ) ./ ( dX + ( eye ( N + 1 ) ) );
% Diagonal entries.
D = D – diag ( sum ( D’ ) );
return
end I am trying to understand how the FFT of different directions in MATLAB works to reproduce in C/C++ instead.
So far I have the following simple example in MATLAB:
clearvars; clc; close all;
%3D FFT test
Nx = 8;
Ny = 4;
Nz= 6;
Lx =16;
Ly = 6;
dx = Lx/Nx;
dy = Ly/Ny;
%———–
xi_x = (2*pi)/Lx;
yi_y = (2*pi)/Ly;
xi = ((0:Nx-1)/Nx)*(2*pi);
yi = ((0:Ny-1)/Ny)*(2*pi);
x = xi/xi_x;
y = yi/yi_y;
zlow = 0; %a
zupp =6; %b
Lz = (zupp-zlow);
eta_zgl = 2/Lz;
[D,zgl] = cheb(Nz);
zgl = (1/2)*(((zupp-zlow)*zgl) + (zupp+zlow));
[X,Z,Y] = meshgrid(x,zgl,y); %this gives 3d grid with z-by-x-by-y size (i.e. ZXY)
%ICs
A = 2*pi / Lx;
B = 2*pi / Ly;
u = (Z-zlow) .* (Z-zupp) .* sin(A*X).* sin(B*Y);
uh1 =(fft(u,[],3));%ZXY
uh2 =(fft(u,[],1));%ZXY
uh3 =(fft(u,[],2));%ZXY
So, in C/C++ I have a 3D tensor with (Nz+1) rows and Nx coumns and Ny matrices and taking the 1D FFT along each "row" of u returns the same results as the following in MATLAB:
uh3 =(fft(u,[],2));%ZXY
While taking the 1D FFT of u along each column of u in C/C++ returns the same result as the following in MATLAB:
uh2 =(fft(u,[],1));%ZXY
Then my question is what does this 1D FFT represent? and how should I represent it in C/C++?
uh1 =(fft(u,[],3));%ZXY
The cheb(N) function is:
function [ D, x ] = cheb ( N )
if ( N == 0 )
D = 0.0;
x = 1.0;
return
end
x = cos ( pi * ( 0 : N ) / N )’;
c = [ 2.0; ones(N-1,1); 2.0 ] .* (-1.0).^(0:N)’;
X = repmat ( x, 1, N + 1 );
dX = X – X’;
% Set the off diagonal entries.
D =( c * (1.0 ./ c )’ ) ./ ( dX + ( eye ( N + 1 ) ) );
% Diagonal entries.
D = D – diag ( sum ( D’ ) );
return
end meshgrid, fft, numerical libraries, c/c++ MATLAB Answers — New Questions
Moving variables between episodes
To use matlab for RL, I have defined the action and observation space and the agent in a .m file, which also calls a reset function and step function also defined in .m files, and not in simulink. How can I move this variables when Matlab is still running the function train(agent,env)? I want to normalize all discounted rewards across all episodes.To use matlab for RL, I have defined the action and observation space and the agent in a .m file, which also calls a reset function and step function also defined in .m files, and not in simulink. How can I move this variables when Matlab is still running the function train(agent,env)? I want to normalize all discounted rewards across all episodes. To use matlab for RL, I have defined the action and observation space and the agent in a .m file, which also calls a reset function and step function also defined in .m files, and not in simulink. How can I move this variables when Matlab is still running the function train(agent,env)? I want to normalize all discounted rewards across all episodes. reinforcement MATLAB Answers — New Questions
Abnormal exit error while running model advisor check
I am facing below error while running MA check ‘Check Stateflow charts for strong data typing’.
Error: Abnormal exist: Invalid or deleted object
Attaching screenshot for reference. Please help to solve this.I am facing below error while running MA check ‘Check Stateflow charts for strong data typing’.
Error: Abnormal exist: Invalid or deleted object
Attaching screenshot for reference. Please help to solve this. I am facing below error while running MA check ‘Check Stateflow charts for strong data typing’.
Error: Abnormal exist: Invalid or deleted object
Attaching screenshot for reference. Please help to solve this. model advisor, check stateflow charts for strong data typing MATLAB Answers — New Questions
Auto Signalize support for Left Hand Side driving
The Signal tool has a very useful Auto Signalize feature allowing you to automatically add and setup traffic lights at a junction. However, only Right Hand Side driving is supported as you can see by the last two options: 4 Way Protected Left and 4 Way Permitted Left. When designing maps for Left Hand Side driving environments all the Signal Lights need to be manually edited to inverse their internal setup. This is extremely tedious and error prone.
Is there a way to automate this process? Are there any plans to add LHS support to the Auto-Signalize feature?The Signal tool has a very useful Auto Signalize feature allowing you to automatically add and setup traffic lights at a junction. However, only Right Hand Side driving is supported as you can see by the last two options: 4 Way Protected Left and 4 Way Permitted Left. When designing maps for Left Hand Side driving environments all the Signal Lights need to be manually edited to inverse their internal setup. This is extremely tedious and error prone.
Is there a way to automate this process? Are there any plans to add LHS support to the Auto-Signalize feature? The Signal tool has a very useful Auto Signalize feature allowing you to automatically add and setup traffic lights at a junction. However, only Right Hand Side driving is supported as you can see by the last two options: 4 Way Protected Left and 4 Way Permitted Left. When designing maps for Left Hand Side driving environments all the Signal Lights need to be manually edited to inverse their internal setup. This is extremely tedious and error prone.
Is there a way to automate this process? Are there any plans to add LHS support to the Auto-Signalize feature? road runner, traffic light MATLAB Answers — New Questions
Derivative of state ‘1’ in block ‘two_area_LFC_PID/Integrator9’ at time 8.820174943555763 is not finite.
I have simulated a system in Simulink MATLAB that I want to optimize with the PID controller.
To find the best controller coefficients, I use WOA optimization method. But when I run it, I get the following error “Derivative of state ‘1’ in block ‘two_area_LFC_PID/Integrator9’ at time 8.820174943555763 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)”. Is there a solution to my problem? I have changed the step size. I also changed the solver to ODE 15s(stiff/NDF). But the problem was not solved. I have posted the desired system image with algorithm codes for friends.
CODE:
function bestSolution = EWOA_Run_PID()
% Step 1: Initialize the input arguments for EWOA
nVar = 6;
ub = [50 50 50 50 50 50];
lb = [0.01 0.01 0.01 0.01 0.01 0.01];
MaxIter = 50;
PopulationSize = 50;
% Step 2: Define the objective function handle using EWAO_Cost_PID_CF_CE
objFcn = @(params) EWOA_Cost_PID(params);
% Step 3: Call the EWOA function
bestSolution = EWOA(nVar, lb, ub, objFcn, MaxIter, PopulationSize);
end
function bestSolution = EWOA(nVar, lb, ub, objFcn, MaxIter, PopulationSize)
% Step 1: Initialize the population
whalesPositions = bsxfun(@plus, lb, bsxfun(@times, rand(PopulationSize, nVar), (ub – lb)));
% Step 2: Evaluate the objective function for each whale
whalesCost = zeros(PopulationSize, 1);
for i = 1:PopulationSize
whalesCost(i) = objFcn(whalesPositions(i, :));
end
% Step 3: Set the initial best position and cost
[globalBestCost, gBestIndex] = min(whalesCost);
globalBestPosition = whalesPositions(gBestIndex, :);
% Step 4: Initialize elite whale
eliteWhalePosition = globalBestPosition;
eliteWhaleCost = globalBestCost;
% Step 5: Set the termination criterion parameters
maxIterWithoutImprovement = 50; % Adjust this value as needed
iterWithoutImprovement = 50;
% Main loop
for iter = 1:MaxIter
a = 2 – iter * ((2) / MaxIter); % Parameter to control the search space reduction
for i = 1:PopulationSize
% Generate random vectors
r1 = rand(1, nVar);
r2 = rand(1, nVar);
% Calculate the A and C coefficients
A = 2 * a * r1 – a;
C = 2 * r2;
% Update the position of the whales using the WOA operators
D = abs(C .* globalBestPosition – whalesPositions(i, :));
newWhalePosition = globalBestPosition – A .* D;
% Clip positions to stay within the bounds
newWhalePosition = max(newWhalePosition, lb);
newWhalePosition = min(newWhalePosition, ub);
% Evaluate the new position using the EWAO_Cost_PID_CF_CE function
newWhaleCost = EWOA_Cost_PID(newWhalePosition);
% Update the whale’s position and cost if a better solution is found
if newWhaleCost < whalesCost(i)
whalesPositions(i, 🙂 = newWhalePosition;
whalesCost(i) = newWhaleCost;
end
% Update the global best position and cost if a better solution is found
if whalesCost(i) < globalBestCost
globalBestCost = whalesCost(i);
globalBestPosition = whalesPositions(i, :);
end
end
% Check for termination criterion
if globalBestCost < eliteWhaleCost
eliteWhalePosition = globalBestPosition;
eliteWhaleCost = globalBestCost;
iterWithoutImprovement = 0;
else
iterWithoutImprovement = iterWithoutImprovement + 1;
end
% Display the best cost at each iteration
disp([‘Iteration ‘, num2str(iter), ‘: Best Cost = ‘, num2str(eliteWhaleCost)]);
% Check if termination criterion is met
if iterWithoutImprovement >= maxIterWithoutImprovement
break;
end
end
% Output the best solution found
bestSolution = eliteWhalePosition;
end
Code
function cost = EWOA_Cost_PID(params)
% Assign parameters to the base workspace using assignin
assignin(‘base’, ‘KP’, params(1));
assignin(‘base’, ‘KI’, params(2));
assignin(‘base’, ‘KD’, params(3));
assignin(‘base’, ‘KPP’, params(4));
assignin(‘base’, ‘KII’, params(5));
assignin(‘base’, ‘KDD’, params(6));
% Run the Simulink model
sim(‘two_area_LFC_PID’);
% Calculate penalties based on maximum absolute values of signals
g1 = max(abs(f1.signals.values)) – 0.25;
g2 = max(abs(f2.signals.values)) – 0.25;
g3 = max(abs(pt.signals.values)) – 0.05;
% Define a large penalty coefficient
lambda = 10^20;
% Compute penalties for constraint violations
Penalty1 = lambda * g1^2 * GetInequality(g1);
Penalty2 = lambda * g2^2 * GetInequality(g2);
Penalty3 = lambda * g3^2 * GetInequality(g3);
% Calculate the total cost
cost = J_obj.signals.values(end) + Penalty1 + Penalty2 + Penalty3;
endI have simulated a system in Simulink MATLAB that I want to optimize with the PID controller.
To find the best controller coefficients, I use WOA optimization method. But when I run it, I get the following error “Derivative of state ‘1’ in block ‘two_area_LFC_PID/Integrator9’ at time 8.820174943555763 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)”. Is there a solution to my problem? I have changed the step size. I also changed the solver to ODE 15s(stiff/NDF). But the problem was not solved. I have posted the desired system image with algorithm codes for friends.
CODE:
function bestSolution = EWOA_Run_PID()
% Step 1: Initialize the input arguments for EWOA
nVar = 6;
ub = [50 50 50 50 50 50];
lb = [0.01 0.01 0.01 0.01 0.01 0.01];
MaxIter = 50;
PopulationSize = 50;
% Step 2: Define the objective function handle using EWAO_Cost_PID_CF_CE
objFcn = @(params) EWOA_Cost_PID(params);
% Step 3: Call the EWOA function
bestSolution = EWOA(nVar, lb, ub, objFcn, MaxIter, PopulationSize);
end
function bestSolution = EWOA(nVar, lb, ub, objFcn, MaxIter, PopulationSize)
% Step 1: Initialize the population
whalesPositions = bsxfun(@plus, lb, bsxfun(@times, rand(PopulationSize, nVar), (ub – lb)));
% Step 2: Evaluate the objective function for each whale
whalesCost = zeros(PopulationSize, 1);
for i = 1:PopulationSize
whalesCost(i) = objFcn(whalesPositions(i, :));
end
% Step 3: Set the initial best position and cost
[globalBestCost, gBestIndex] = min(whalesCost);
globalBestPosition = whalesPositions(gBestIndex, :);
% Step 4: Initialize elite whale
eliteWhalePosition = globalBestPosition;
eliteWhaleCost = globalBestCost;
% Step 5: Set the termination criterion parameters
maxIterWithoutImprovement = 50; % Adjust this value as needed
iterWithoutImprovement = 50;
% Main loop
for iter = 1:MaxIter
a = 2 – iter * ((2) / MaxIter); % Parameter to control the search space reduction
for i = 1:PopulationSize
% Generate random vectors
r1 = rand(1, nVar);
r2 = rand(1, nVar);
% Calculate the A and C coefficients
A = 2 * a * r1 – a;
C = 2 * r2;
% Update the position of the whales using the WOA operators
D = abs(C .* globalBestPosition – whalesPositions(i, :));
newWhalePosition = globalBestPosition – A .* D;
% Clip positions to stay within the bounds
newWhalePosition = max(newWhalePosition, lb);
newWhalePosition = min(newWhalePosition, ub);
% Evaluate the new position using the EWAO_Cost_PID_CF_CE function
newWhaleCost = EWOA_Cost_PID(newWhalePosition);
% Update the whale’s position and cost if a better solution is found
if newWhaleCost < whalesCost(i)
whalesPositions(i, 🙂 = newWhalePosition;
whalesCost(i) = newWhaleCost;
end
% Update the global best position and cost if a better solution is found
if whalesCost(i) < globalBestCost
globalBestCost = whalesCost(i);
globalBestPosition = whalesPositions(i, :);
end
end
% Check for termination criterion
if globalBestCost < eliteWhaleCost
eliteWhalePosition = globalBestPosition;
eliteWhaleCost = globalBestCost;
iterWithoutImprovement = 0;
else
iterWithoutImprovement = iterWithoutImprovement + 1;
end
% Display the best cost at each iteration
disp([‘Iteration ‘, num2str(iter), ‘: Best Cost = ‘, num2str(eliteWhaleCost)]);
% Check if termination criterion is met
if iterWithoutImprovement >= maxIterWithoutImprovement
break;
end
end
% Output the best solution found
bestSolution = eliteWhalePosition;
end
Code
function cost = EWOA_Cost_PID(params)
% Assign parameters to the base workspace using assignin
assignin(‘base’, ‘KP’, params(1));
assignin(‘base’, ‘KI’, params(2));
assignin(‘base’, ‘KD’, params(3));
assignin(‘base’, ‘KPP’, params(4));
assignin(‘base’, ‘KII’, params(5));
assignin(‘base’, ‘KDD’, params(6));
% Run the Simulink model
sim(‘two_area_LFC_PID’);
% Calculate penalties based on maximum absolute values of signals
g1 = max(abs(f1.signals.values)) – 0.25;
g2 = max(abs(f2.signals.values)) – 0.25;
g3 = max(abs(pt.signals.values)) – 0.05;
% Define a large penalty coefficient
lambda = 10^20;
% Compute penalties for constraint violations
Penalty1 = lambda * g1^2 * GetInequality(g1);
Penalty2 = lambda * g2^2 * GetInequality(g2);
Penalty3 = lambda * g3^2 * GetInequality(g3);
% Calculate the total cost
cost = J_obj.signals.values(end) + Penalty1 + Penalty2 + Penalty3;
end I have simulated a system in Simulink MATLAB that I want to optimize with the PID controller.
To find the best controller coefficients, I use WOA optimization method. But when I run it, I get the following error “Derivative of state ‘1’ in block ‘two_area_LFC_PID/Integrator9’ at time 8.820174943555763 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)”. Is there a solution to my problem? I have changed the step size. I also changed the solver to ODE 15s(stiff/NDF). But the problem was not solved. I have posted the desired system image with algorithm codes for friends.
CODE:
function bestSolution = EWOA_Run_PID()
% Step 1: Initialize the input arguments for EWOA
nVar = 6;
ub = [50 50 50 50 50 50];
lb = [0.01 0.01 0.01 0.01 0.01 0.01];
MaxIter = 50;
PopulationSize = 50;
% Step 2: Define the objective function handle using EWAO_Cost_PID_CF_CE
objFcn = @(params) EWOA_Cost_PID(params);
% Step 3: Call the EWOA function
bestSolution = EWOA(nVar, lb, ub, objFcn, MaxIter, PopulationSize);
end
function bestSolution = EWOA(nVar, lb, ub, objFcn, MaxIter, PopulationSize)
% Step 1: Initialize the population
whalesPositions = bsxfun(@plus, lb, bsxfun(@times, rand(PopulationSize, nVar), (ub – lb)));
% Step 2: Evaluate the objective function for each whale
whalesCost = zeros(PopulationSize, 1);
for i = 1:PopulationSize
whalesCost(i) = objFcn(whalesPositions(i, :));
end
% Step 3: Set the initial best position and cost
[globalBestCost, gBestIndex] = min(whalesCost);
globalBestPosition = whalesPositions(gBestIndex, :);
% Step 4: Initialize elite whale
eliteWhalePosition = globalBestPosition;
eliteWhaleCost = globalBestCost;
% Step 5: Set the termination criterion parameters
maxIterWithoutImprovement = 50; % Adjust this value as needed
iterWithoutImprovement = 50;
% Main loop
for iter = 1:MaxIter
a = 2 – iter * ((2) / MaxIter); % Parameter to control the search space reduction
for i = 1:PopulationSize
% Generate random vectors
r1 = rand(1, nVar);
r2 = rand(1, nVar);
% Calculate the A and C coefficients
A = 2 * a * r1 – a;
C = 2 * r2;
% Update the position of the whales using the WOA operators
D = abs(C .* globalBestPosition – whalesPositions(i, :));
newWhalePosition = globalBestPosition – A .* D;
% Clip positions to stay within the bounds
newWhalePosition = max(newWhalePosition, lb);
newWhalePosition = min(newWhalePosition, ub);
% Evaluate the new position using the EWAO_Cost_PID_CF_CE function
newWhaleCost = EWOA_Cost_PID(newWhalePosition);
% Update the whale’s position and cost if a better solution is found
if newWhaleCost < whalesCost(i)
whalesPositions(i, 🙂 = newWhalePosition;
whalesCost(i) = newWhaleCost;
end
% Update the global best position and cost if a better solution is found
if whalesCost(i) < globalBestCost
globalBestCost = whalesCost(i);
globalBestPosition = whalesPositions(i, :);
end
end
% Check for termination criterion
if globalBestCost < eliteWhaleCost
eliteWhalePosition = globalBestPosition;
eliteWhaleCost = globalBestCost;
iterWithoutImprovement = 0;
else
iterWithoutImprovement = iterWithoutImprovement + 1;
end
% Display the best cost at each iteration
disp([‘Iteration ‘, num2str(iter), ‘: Best Cost = ‘, num2str(eliteWhaleCost)]);
% Check if termination criterion is met
if iterWithoutImprovement >= maxIterWithoutImprovement
break;
end
end
% Output the best solution found
bestSolution = eliteWhalePosition;
end
Code
function cost = EWOA_Cost_PID(params)
% Assign parameters to the base workspace using assignin
assignin(‘base’, ‘KP’, params(1));
assignin(‘base’, ‘KI’, params(2));
assignin(‘base’, ‘KD’, params(3));
assignin(‘base’, ‘KPP’, params(4));
assignin(‘base’, ‘KII’, params(5));
assignin(‘base’, ‘KDD’, params(6));
% Run the Simulink model
sim(‘two_area_LFC_PID’);
% Calculate penalties based on maximum absolute values of signals
g1 = max(abs(f1.signals.values)) – 0.25;
g2 = max(abs(f2.signals.values)) – 0.25;
g3 = max(abs(pt.signals.values)) – 0.05;
% Define a large penalty coefficient
lambda = 10^20;
% Compute penalties for constraint violations
Penalty1 = lambda * g1^2 * GetInequality(g1);
Penalty2 = lambda * g2^2 * GetInequality(g2);
Penalty3 = lambda * g3^2 * GetInequality(g3);
% Calculate the total cost
cost = J_obj.signals.values(end) + Penalty1 + Penalty2 + Penalty3;
end error, matlab, solve, derivative of state ‘1’ in block MATLAB Answers — New Questions
how to see a serdes channel’s frequency response in simulink?
I opened the example "Architectural 112G PAM4 ADC-Based SerDes Model", and I want to see the channel’s frequency response.
I tried function "frestimate" but it didn’t work.I opened the example "Architectural 112G PAM4 ADC-Based SerDes Model", and I want to see the channel’s frequency response.
I tried function "frestimate" but it didn’t work. I opened the example "Architectural 112G PAM4 ADC-Based SerDes Model", and I want to see the channel’s frequency response.
I tried function "frestimate" but it didn’t work. serdes, frequency response, channel loss, simulink MATLAB Answers — New Questions