Month: February 2025
Making a heat map from three vectors of different lengths
From a set of three vectors (x,y,z), I want to generate a heat map of x,y and z where the color bar would denote z-values.Perhaps this answer was relevant https://www.mathworks.com/matlabcentral/answers/105390-making-a-heat-map-from-three-vectorsBut it was erased from the database. Thanks!From a set of three vectors (x,y,z), I want to generate a heat map of x,y and z where the color bar would denote z-values.Perhaps this answer was relevant https://www.mathworks.com/matlabcentral/answers/105390-making-a-heat-map-from-three-vectorsBut it was erased from the database. Thanks! From a set of three vectors (x,y,z), I want to generate a heat map of x,y and z where the color bar would denote z-values.Perhaps this answer was relevant https://www.mathworks.com/matlabcentral/answers/105390-making-a-heat-map-from-three-vectorsBut it was erased from the database. Thanks! heat map, concatenate MATLAB Answers — New Questions
problem to solve incorrrect
%% R-RRR
clear all; clc; close all
% Input data
AB=0.325; %(m)
BC=0.938; %(m)
CD=0.675; %(m)
CE=0.6; %(m)
xD=0.8; %(m)
yD=-0.432; %(m)
phi =pi; %(rad)
xA = 0; yA = 0;
rA = [xA yA 0];
rD = [xD yD 0];
xB = AB*cos(phi); yB = AB*sin(phi); rB = [xB yB 0];
% Position of joint C
%
eqnC1 = ‘(xCsol – xB)^2 + (yCsol – yB)^2 = BC^2 ‘;
% Distance formula: CD=constant
eqnC2 = ‘(xCsol – xD)^2 + (yCsol – yD)^2 = CD^2 ‘;
% Simultaneously solve above equations
solC = solve(eqnC1, eqnC2, ‘xCsol, yCsol’);
% Two solutions for xC – vector form
xCpositions = eval(solC.xCsol);
% Two solutions for yC – vector form
yCpositions = eval(solC.yCsol);
% Separate the solutions in scalar form
% first component of the vector xCpositions
xC1 = xCpositions(1);
% second component of the vector xCpositions
xC2 = xCpositions(2);
yC1 = yCpositions(1);
% second component of the vector yCpositions
yC2 = yCpositions(2);
% Select the correct position for C
% for the given input angle
if xC1 > xD
xC = xC1; yC=yC1;
else
xC = xC2; yC=yC2;
end
rC = [xC yC 0]; % Position vector of C
% Position of joint E
% Distance formula: CE=constant
eqnE1='(xEsol-xC)^2+(yEsol-yC)^2=CE^2′;
% Slope formula:
% E, C, and D are on the same straight line
eqnE2='(yD-yC)/(xD-xC)=(yEsol-yC)/(xEsol-xC)’;
solE = solve(eqnE1, eqnE2, ‘xEsol, yEsol’);
xEpositions = eval(solE.xEsol);
yEpositions = eval(solE.yEsol);
xE1 = xEpositions(1); xE2 = xEpositions(2);
yE1 = yEpositions(1); yE2 = yEpositions(2);
if xE1 < xC
xE = xE1; yE=yE1;
else
xE = xE2; yE=yE2;
end
rE = [xE yE 0]; % Position vector of E
% Angles of the links with the horizontal
phi2 = atan((yB-yC)/(xB-xC));
phi3 = atan((yD-yC)/(xD-xC));
fprintf(‘Results nn’)
fprintf(‘rA = [ %g, %g, %g ] (m)n’, rA)
fprintf(‘rD = [ %g, %g, %g ] (m)n’, rD)
fprintf(‘rB = [ %g, %g, %g ] (m)n’, rB)
fprintf(‘rC = [ %g, %g, %g ] (m)n’, rC)
fprintf(‘rE = [ %g, %g, %g ] (m)n’, rE)
fprintf(‘phi2 = %g (degrees) n’, phi2*180/pi)
fprintf(‘phi3 = %g (degrees) n’, phi3*180/pi)
% Graphic of the mechanism
plot([xA,xB],[yA,yB],’k-o’,’LineWidth’,1.5)
hold on % holds the current plot
plot([xB,xC],[yB,yC],’b-o’,’LineWidth’,1.5)
hold on
plot([xD,xE],[yD,yE],’r-o’,’LineWidth’,1.5)
% adds major grid lines to the current axes
grid on,…
xlabel(‘x (m)’), ylabel(‘y (m)’),…
title(‘positions for phi = 45 (deg)’),…
text(xA,yA,’leftarrow A = ground’,…
‘HorizontalAlignment’,’left’),…
text(xB,yB,’ B’),…
text(xC,yC,’leftarrow C = ground’,…
‘HorizontalAlignment’,’left’),…
text(xD,yD,’leftarrow D = ground’,…
‘HorizontalAlignment’,’left’),…
text(xE,yE,’ E’), axis([-2 3 -2 3])%% R-RRR
clear all; clc; close all
% Input data
AB=0.325; %(m)
BC=0.938; %(m)
CD=0.675; %(m)
CE=0.6; %(m)
xD=0.8; %(m)
yD=-0.432; %(m)
phi =pi; %(rad)
xA = 0; yA = 0;
rA = [xA yA 0];
rD = [xD yD 0];
xB = AB*cos(phi); yB = AB*sin(phi); rB = [xB yB 0];
% Position of joint C
%
eqnC1 = ‘(xCsol – xB)^2 + (yCsol – yB)^2 = BC^2 ‘;
% Distance formula: CD=constant
eqnC2 = ‘(xCsol – xD)^2 + (yCsol – yD)^2 = CD^2 ‘;
% Simultaneously solve above equations
solC = solve(eqnC1, eqnC2, ‘xCsol, yCsol’);
% Two solutions for xC – vector form
xCpositions = eval(solC.xCsol);
% Two solutions for yC – vector form
yCpositions = eval(solC.yCsol);
% Separate the solutions in scalar form
% first component of the vector xCpositions
xC1 = xCpositions(1);
% second component of the vector xCpositions
xC2 = xCpositions(2);
yC1 = yCpositions(1);
% second component of the vector yCpositions
yC2 = yCpositions(2);
% Select the correct position for C
% for the given input angle
if xC1 > xD
xC = xC1; yC=yC1;
else
xC = xC2; yC=yC2;
end
rC = [xC yC 0]; % Position vector of C
% Position of joint E
% Distance formula: CE=constant
eqnE1='(xEsol-xC)^2+(yEsol-yC)^2=CE^2′;
% Slope formula:
% E, C, and D are on the same straight line
eqnE2='(yD-yC)/(xD-xC)=(yEsol-yC)/(xEsol-xC)’;
solE = solve(eqnE1, eqnE2, ‘xEsol, yEsol’);
xEpositions = eval(solE.xEsol);
yEpositions = eval(solE.yEsol);
xE1 = xEpositions(1); xE2 = xEpositions(2);
yE1 = yEpositions(1); yE2 = yEpositions(2);
if xE1 < xC
xE = xE1; yE=yE1;
else
xE = xE2; yE=yE2;
end
rE = [xE yE 0]; % Position vector of E
% Angles of the links with the horizontal
phi2 = atan((yB-yC)/(xB-xC));
phi3 = atan((yD-yC)/(xD-xC));
fprintf(‘Results nn’)
fprintf(‘rA = [ %g, %g, %g ] (m)n’, rA)
fprintf(‘rD = [ %g, %g, %g ] (m)n’, rD)
fprintf(‘rB = [ %g, %g, %g ] (m)n’, rB)
fprintf(‘rC = [ %g, %g, %g ] (m)n’, rC)
fprintf(‘rE = [ %g, %g, %g ] (m)n’, rE)
fprintf(‘phi2 = %g (degrees) n’, phi2*180/pi)
fprintf(‘phi3 = %g (degrees) n’, phi3*180/pi)
% Graphic of the mechanism
plot([xA,xB],[yA,yB],’k-o’,’LineWidth’,1.5)
hold on % holds the current plot
plot([xB,xC],[yB,yC],’b-o’,’LineWidth’,1.5)
hold on
plot([xD,xE],[yD,yE],’r-o’,’LineWidth’,1.5)
% adds major grid lines to the current axes
grid on,…
xlabel(‘x (m)’), ylabel(‘y (m)’),…
title(‘positions for phi = 45 (deg)’),…
text(xA,yA,’leftarrow A = ground’,…
‘HorizontalAlignment’,’left’),…
text(xB,yB,’ B’),…
text(xC,yC,’leftarrow C = ground’,…
‘HorizontalAlignment’,’left’),…
text(xD,yD,’leftarrow D = ground’,…
‘HorizontalAlignment’,’left’),…
text(xE,yE,’ E’), axis([-2 3 -2 3]) %% R-RRR
clear all; clc; close all
% Input data
AB=0.325; %(m)
BC=0.938; %(m)
CD=0.675; %(m)
CE=0.6; %(m)
xD=0.8; %(m)
yD=-0.432; %(m)
phi =pi; %(rad)
xA = 0; yA = 0;
rA = [xA yA 0];
rD = [xD yD 0];
xB = AB*cos(phi); yB = AB*sin(phi); rB = [xB yB 0];
% Position of joint C
%
eqnC1 = ‘(xCsol – xB)^2 + (yCsol – yB)^2 = BC^2 ‘;
% Distance formula: CD=constant
eqnC2 = ‘(xCsol – xD)^2 + (yCsol – yD)^2 = CD^2 ‘;
% Simultaneously solve above equations
solC = solve(eqnC1, eqnC2, ‘xCsol, yCsol’);
% Two solutions for xC – vector form
xCpositions = eval(solC.xCsol);
% Two solutions for yC – vector form
yCpositions = eval(solC.yCsol);
% Separate the solutions in scalar form
% first component of the vector xCpositions
xC1 = xCpositions(1);
% second component of the vector xCpositions
xC2 = xCpositions(2);
yC1 = yCpositions(1);
% second component of the vector yCpositions
yC2 = yCpositions(2);
% Select the correct position for C
% for the given input angle
if xC1 > xD
xC = xC1; yC=yC1;
else
xC = xC2; yC=yC2;
end
rC = [xC yC 0]; % Position vector of C
% Position of joint E
% Distance formula: CE=constant
eqnE1='(xEsol-xC)^2+(yEsol-yC)^2=CE^2′;
% Slope formula:
% E, C, and D are on the same straight line
eqnE2='(yD-yC)/(xD-xC)=(yEsol-yC)/(xEsol-xC)’;
solE = solve(eqnE1, eqnE2, ‘xEsol, yEsol’);
xEpositions = eval(solE.xEsol);
yEpositions = eval(solE.yEsol);
xE1 = xEpositions(1); xE2 = xEpositions(2);
yE1 = yEpositions(1); yE2 = yEpositions(2);
if xE1 < xC
xE = xE1; yE=yE1;
else
xE = xE2; yE=yE2;
end
rE = [xE yE 0]; % Position vector of E
% Angles of the links with the horizontal
phi2 = atan((yB-yC)/(xB-xC));
phi3 = atan((yD-yC)/(xD-xC));
fprintf(‘Results nn’)
fprintf(‘rA = [ %g, %g, %g ] (m)n’, rA)
fprintf(‘rD = [ %g, %g, %g ] (m)n’, rD)
fprintf(‘rB = [ %g, %g, %g ] (m)n’, rB)
fprintf(‘rC = [ %g, %g, %g ] (m)n’, rC)
fprintf(‘rE = [ %g, %g, %g ] (m)n’, rE)
fprintf(‘phi2 = %g (degrees) n’, phi2*180/pi)
fprintf(‘phi3 = %g (degrees) n’, phi3*180/pi)
% Graphic of the mechanism
plot([xA,xB],[yA,yB],’k-o’,’LineWidth’,1.5)
hold on % holds the current plot
plot([xB,xC],[yB,yC],’b-o’,’LineWidth’,1.5)
hold on
plot([xD,xE],[yD,yE],’r-o’,’LineWidth’,1.5)
% adds major grid lines to the current axes
grid on,…
xlabel(‘x (m)’), ylabel(‘y (m)’),…
title(‘positions for phi = 45 (deg)’),…
text(xA,yA,’leftarrow A = ground’,…
‘HorizontalAlignment’,’left’),…
text(xB,yB,’ B’),…
text(xC,yC,’leftarrow C = ground’,…
‘HorizontalAlignment’,’left’),…
text(xD,yD,’leftarrow D = ground’,…
‘HorizontalAlignment’,’left’),…
text(xE,yE,’ E’), axis([-2 3 -2 3]) plot MATLAB Answers — New Questions
Singularity error – Simulink
An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘1’ in block ‘XXXXXX/Receiver/pre-amp/CTLE mode 2/Transfer Fcn15’ at time 3.3003349235944607E-9 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)
Please help.An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘1’ in block ‘XXXXXX/Receiver/pre-amp/CTLE mode 2/Transfer Fcn15’ at time 3.3003349235944607E-9 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)
Please help. An error occurred while running the simulation and the simulation was terminated
Caused by:
Derivative of state ‘1’ in block ‘XXXXXX/Receiver/pre-amp/CTLE mode 2/Transfer Fcn15’ at time 3.3003349235944607E-9 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)
Please help. simulink MATLAB Answers — New Questions
When DDPG optimizes PID parameters, how do I keep the first 10s of data from the system stabilization phase out of the experienceBuffer?
Adaptive PID control using simulink’s own Agent. Since the first 20 is a buffer process for the system, the first 20s are not part of the transition process, but are necessary to exist. How to make the Agent block the first 20s of action, state, reward and other information, or how to make the first 20s does not affect the training effect. In fact, if the first 10s are learned by the intelligent body, then the training effect is very poor.Adaptive PID control using simulink’s own Agent. Since the first 20 is a buffer process for the system, the first 20s are not part of the transition process, but are necessary to exist. How to make the Agent block the first 20s of action, state, reward and other information, or how to make the first 20s does not affect the training effect. In fact, if the first 10s are learned by the intelligent body, then the training effect is very poor. Adaptive PID control using simulink’s own Agent. Since the first 20 is a buffer process for the system, the first 20s are not part of the transition process, but are necessary to exist. How to make the Agent block the first 20s of action, state, reward and other information, or how to make the first 20s does not affect the training effect. In fact, if the first 10s are learned by the intelligent body, then the training effect is very poor. reinforcement learning, simulink, agent MATLAB Answers — New Questions
Distinguish land from ocean in harbors
I’m trying to distinguish land from ocean in harbors and have tried using the highest resolution maps from gshhs, but it isn’t detailed enough. Below are is an example showing that it isn’t detailed to the level I want. The one to the left showing th coastline boundaries and the other one showing the geoplot with basemap = ‘streets’
Since the map is able to plot in such detail, shown below, I would imagine that it should be able to distingusih land from ocean, just based on the colors.
Appriciate any help here! Thanks in advance.I’m trying to distinguish land from ocean in harbors and have tried using the highest resolution maps from gshhs, but it isn’t detailed enough. Below are is an example showing that it isn’t detailed to the level I want. The one to the left showing th coastline boundaries and the other one showing the geoplot with basemap = ‘streets’
Since the map is able to plot in such detail, shown below, I would imagine that it should be able to distingusih land from ocean, just based on the colors.
Appriciate any help here! Thanks in advance. I’m trying to distinguish land from ocean in harbors and have tried using the highest resolution maps from gshhs, but it isn’t detailed enough. Below are is an example showing that it isn’t detailed to the level I want. The one to the left showing th coastline boundaries and the other one showing the geoplot with basemap = ‘streets’
Since the map is able to plot in such detail, shown below, I would imagine that it should be able to distingusih land from ocean, just based on the colors.
Appriciate any help here! Thanks in advance. geoplot, plot, colormap, map, marine, figure, gshhg MATLAB Answers — New Questions
sinusoidal representation networks or SIRENs
Hi there!
I am wondering if there is the matlab code for sinusoidal representation networks or SIRENs, which are suitable for solving PDEs in the frame of PINNs. The activation function of an SIREN in sin function, this activation layer has not been built in Matlab.
Thanks for any help.Hi there!
I am wondering if there is the matlab code for sinusoidal representation networks or SIRENs, which are suitable for solving PDEs in the frame of PINNs. The activation function of an SIREN in sin function, this activation layer has not been built in Matlab.
Thanks for any help. Hi there!
I am wondering if there is the matlab code for sinusoidal representation networks or SIRENs, which are suitable for solving PDEs in the frame of PINNs. The activation function of an SIREN in sin function, this activation layer has not been built in Matlab.
Thanks for any help. deep learning, pinns, siren MATLAB Answers — New Questions
I have an equation. I want to adjust one of the values in the equation until it hits a certain output. How do I run a loop to increment that certain value until it does this?
equation: X/Y=P
Increase Y by an increment of 1 until gives an output equal or less than P.
Example:
X=21
Y=4
P=3
equation: 21/4=5.25
GOAL: increment Y unitl it gives an output less than or equal to P.equation: X/Y=P
Increase Y by an increment of 1 until gives an output equal or less than P.
Example:
X=21
Y=4
P=3
equation: 21/4=5.25
GOAL: increment Y unitl it gives an output less than or equal to P. equation: X/Y=P
Increase Y by an increment of 1 until gives an output equal or less than P.
Example:
X=21
Y=4
P=3
equation: 21/4=5.25
GOAL: increment Y unitl it gives an output less than or equal to P. if loop, for loop, if else, if else statement MATLAB Answers — New Questions
transformPointsForward does not support PolynomialTransformation2D
I would like to know why transformPointsForward does not support PolynomialTransformation2D as a transformation object. It is weird because transformPointsInverse does support PolynomialTransformation2D.
So the workaround is simple, instead of using:
tform = fitgeotform2d(movingPoints,fixedPoints,"polynomial",degree)
[x,y] = transformPointsForward(tform,u,v)
I used:
tform = fitgeotform2d(fixedPoints,movingPoints,"polynomial",degree)
[x,y] = transformPointsInverse(tform,u,v)
But it is still counterintuitive and increases the risk of making mistakes later in the code.
Please let me know if there is something I am overlooking or if this is really a missing functionality of the transformPointsForward function.
This is the error I am getting when using transformPointsForward:
Incorrect number or types of inputs or outputs for function transformPointsForward.I would like to know why transformPointsForward does not support PolynomialTransformation2D as a transformation object. It is weird because transformPointsInverse does support PolynomialTransformation2D.
So the workaround is simple, instead of using:
tform = fitgeotform2d(movingPoints,fixedPoints,"polynomial",degree)
[x,y] = transformPointsForward(tform,u,v)
I used:
tform = fitgeotform2d(fixedPoints,movingPoints,"polynomial",degree)
[x,y] = transformPointsInverse(tform,u,v)
But it is still counterintuitive and increases the risk of making mistakes later in the code.
Please let me know if there is something I am overlooking or if this is really a missing functionality of the transformPointsForward function.
This is the error I am getting when using transformPointsForward:
Incorrect number or types of inputs or outputs for function transformPointsForward. I would like to know why transformPointsForward does not support PolynomialTransformation2D as a transformation object. It is weird because transformPointsInverse does support PolynomialTransformation2D.
So the workaround is simple, instead of using:
tform = fitgeotform2d(movingPoints,fixedPoints,"polynomial",degree)
[x,y] = transformPointsForward(tform,u,v)
I used:
tform = fitgeotform2d(fixedPoints,movingPoints,"polynomial",degree)
[x,y] = transformPointsInverse(tform,u,v)
But it is still counterintuitive and increases the risk of making mistakes later in the code.
Please let me know if there is something I am overlooking or if this is really a missing functionality of the transformPointsForward function.
This is the error I am getting when using transformPointsForward:
Incorrect number or types of inputs or outputs for function transformPointsForward. image processing MATLAB Answers — New Questions
vpa, simplify, solve, etc don’t fully simplify symbolic function.
I am doing integration using MATLAB’s symbolic toolbox. I have many functions of my independent variable, z. This is my code, with numbers changed and the problem simplified. I have F1 print at the end just so I can see what the function resolves to.
l = 50;
a = 10;
W = 1200;
syms Q(z);
Q(z) = 1200 + 56*z – 2.5*z^2;
R = – int(Q(z), [0 l]) + W;
syms F1(z) F2(z) F3(z);
F1(z) = simplify(- int(Q(z), [0 z]) – R,"IgnoreAnalyticConstraints",true);
F1
Even with simplify and "IgnoreAnalyticConstraints" being set to true, F1 is in the form "73900/3 – (z*(- 5*z^2 + 168*z + 7200))/6" instead of az^3/b + cz^2/d + ez/f + g, the fully simplified method. vpa just puts all fractions in numeric form, and eval doesn’t really do anything. What am I missing, as I know that there should be some method to this simple operation of simplifying a polynomial.I am doing integration using MATLAB’s symbolic toolbox. I have many functions of my independent variable, z. This is my code, with numbers changed and the problem simplified. I have F1 print at the end just so I can see what the function resolves to.
l = 50;
a = 10;
W = 1200;
syms Q(z);
Q(z) = 1200 + 56*z – 2.5*z^2;
R = – int(Q(z), [0 l]) + W;
syms F1(z) F2(z) F3(z);
F1(z) = simplify(- int(Q(z), [0 z]) – R,"IgnoreAnalyticConstraints",true);
F1
Even with simplify and "IgnoreAnalyticConstraints" being set to true, F1 is in the form "73900/3 – (z*(- 5*z^2 + 168*z + 7200))/6" instead of az^3/b + cz^2/d + ez/f + g, the fully simplified method. vpa just puts all fractions in numeric form, and eval doesn’t really do anything. What am I missing, as I know that there should be some method to this simple operation of simplifying a polynomial. I am doing integration using MATLAB’s symbolic toolbox. I have many functions of my independent variable, z. This is my code, with numbers changed and the problem simplified. I have F1 print at the end just so I can see what the function resolves to.
l = 50;
a = 10;
W = 1200;
syms Q(z);
Q(z) = 1200 + 56*z – 2.5*z^2;
R = – int(Q(z), [0 l]) + W;
syms F1(z) F2(z) F3(z);
F1(z) = simplify(- int(Q(z), [0 z]) – R,"IgnoreAnalyticConstraints",true);
F1
Even with simplify and "IgnoreAnalyticConstraints" being set to true, F1 is in the form "73900/3 – (z*(- 5*z^2 + 168*z + 7200))/6" instead of az^3/b + cz^2/d + ez/f + g, the fully simplified method. vpa just puts all fractions in numeric form, and eval doesn’t really do anything. What am I missing, as I know that there should be some method to this simple operation of simplifying a polynomial. symbolic, function MATLAB Answers — New Questions
Why do I receive a mask initialization error when I run Simulink file in a newer version of Simulink?
Hi,
I can run the Simscape model below in Simulink 2015b:
https://www.mathworks.com/matlabcentral/fileexchange/54771-10-machine-new-england-power-system-ieee-benchmark
However, I am trying to generate a compiled version of this code, which requires using a newer version of Simulink. When I try to run the same code in Simulink 2020b, I get the following error:
"Failed to evaluate mask initialization commands.Caused by:Index exceeds the number of array elements (1)."
It happens in generator G1. I can’t debug it (if I copy and paste the code in Matlab, it can’t find one of the functions").
Any ideas on how to fix this error?Hi,
I can run the Simscape model below in Simulink 2015b:
https://www.mathworks.com/matlabcentral/fileexchange/54771-10-machine-new-england-power-system-ieee-benchmark
However, I am trying to generate a compiled version of this code, which requires using a newer version of Simulink. When I try to run the same code in Simulink 2020b, I get the following error:
"Failed to evaluate mask initialization commands.Caused by:Index exceeds the number of array elements (1)."
It happens in generator G1. I can’t debug it (if I copy and paste the code in Matlab, it can’t find one of the functions").
Any ideas on how to fix this error? Hi,
I can run the Simscape model below in Simulink 2015b:
https://www.mathworks.com/matlabcentral/fileexchange/54771-10-machine-new-england-power-system-ieee-benchmark
However, I am trying to generate a compiled version of this code, which requires using a newer version of Simulink. When I try to run the same code in Simulink 2020b, I get the following error:
"Failed to evaluate mask initialization commands.Caused by:Index exceeds the number of array elements (1)."
It happens in generator G1. I can’t debug it (if I copy and paste the code in Matlab, it can’t find one of the functions").
Any ideas on how to fix this error? simscape, mask initialization error, power system simulation MATLAB Answers — New Questions
Error de Add-On Installer
Hola, Buenos días.
Estoy intentando instalar las Toolbox Simscape, y Simscape Electrical. Todo va bien hasta que al momento de descargar e instalar las Toolbox aparece el siguiente error.
Estoy usando MATLAB R2024aHola, Buenos días.
Estoy intentando instalar las Toolbox Simscape, y Simscape Electrical. Todo va bien hasta que al momento de descargar e instalar las Toolbox aparece el siguiente error.
Estoy usando MATLAB R2024a Hola, Buenos días.
Estoy intentando instalar las Toolbox Simscape, y Simscape Electrical. Todo va bien hasta que al momento de descargar e instalar las Toolbox aparece el siguiente error.
Estoy usando MATLAB R2024a error, addon, toolbox MATLAB Answers — New Questions
not able to copy paste custom simscape component
I am copying custom component to a default matlab example, But getting below error
–>Error evaluating ‘PreCopyFcn’ callback of Converter
(Three-Phase) block (mask) ‘untitled/Converter’.
Callback string is ‘simscape.compiler.sli.internal.callback(‘PreCopyFcn’,gcbh);’
–>Cannot add block Converter to the model because a license for Simscape Electrical is not available.I am copying custom component to a default matlab example, But getting below error
–>Error evaluating ‘PreCopyFcn’ callback of Converter
(Three-Phase) block (mask) ‘untitled/Converter’.
Callback string is ‘simscape.compiler.sli.internal.callback(‘PreCopyFcn’,gcbh);’
–>Cannot add block Converter to the model because a license for Simscape Electrical is not available. I am copying custom component to a default matlab example, But getting below error
–>Error evaluating ‘PreCopyFcn’ callback of Converter
(Three-Phase) block (mask) ‘untitled/Converter’.
Callback string is ‘simscape.compiler.sli.internal.callback(‘PreCopyFcn’,gcbh);’
–>Cannot add block Converter to the model because a license for Simscape Electrical is not available. #error #simulink MATLAB Answers — New Questions
How to use “wget” command in Linux?
I’m trying to run a program that needs to access the "wget" the command as follows:
[result, cmdout] = system(‘wget -h’);
Do you have any suggestions to get it working in Linux?I’m trying to run a program that needs to access the "wget" the command as follows:
[result, cmdout] = system(‘wget -h’);
Do you have any suggestions to get it working in Linux? I’m trying to run a program that needs to access the "wget" the command as follows:
[result, cmdout] = system(‘wget -h’);
Do you have any suggestions to get it working in Linux? wget, websave, url, download MATLAB Answers — New Questions
Why trapz is giving me negative area?
Hey all,
I have two vectors, frequency and power. I’m trying to get the area under the curve of the power plot but it ends up giving me a negative value. When I do trapz(power) alone, it’s a positive value. diff(freq) is also positive. I’m attaching the data for your reference. Thanks!Hey all,
I have two vectors, frequency and power. I’m trying to get the area under the curve of the power plot but it ends up giving me a negative value. When I do trapz(power) alone, it’s a positive value. diff(freq) is also positive. I’m attaching the data for your reference. Thanks! Hey all,
I have two vectors, frequency and power. I’m trying to get the area under the curve of the power plot but it ends up giving me a negative value. When I do trapz(power) alone, it’s a positive value. diff(freq) is also positive. I’m attaching the data for your reference. Thanks! integral, trapz MATLAB Answers — New Questions
Simulink Code Generation Error: Array of Classes Initalization
Hello,
I am trying to built a Simulink function which keeps record of the statistics of the system by using array of classes. However, I can not generate an array of class in Simulink. I realize that I should instantiate an array in Simulink but how can I instantiate a class?
arrivedArray(3, 65536) = queueInfo;
analysisArray(3, 65536) = queueInfo;
In the picture above, queueInfo is my class. This two lines return with the following error.
Code generation requires variable arrivedArray to be fully defined before subscribing it.
By the way, this is the suggested method by Matlab for creating an array of class but somehow it doesn’t work. Later I’ve tried this one:
persistent arrivedArray
if isempty(arrivedArray)
arrivedArray(3, 655336) = queueInfo;
end
persistent analysisArray
if isempty(analysisArray)
analysisArray(3, 65536) = queueInfo;
end
But it doesn’t work either. The error İs:
Persistent variable ‘arrivedArray’ must be assigned before it is used. The only exception is a check using ‘isempty(arrivedArray)’ that can be performed prior to assignment.
I understand the error but have no idea how to fix it. A constructor did not help me too. Here is my class structure:
1
classdef transactionInfo
properties
tag = uint16(0);
arrivalTime = uint64(0);
departureTime = uint64(0);
end
methods
function obj = transactionInfo(v)
if nargin > 0
obj.tag = uint16(v);
obj.arrivalTime = uint64(v);
obj.departureTime = uint64(v);
end
end
end
end
2
classdef queueInfo < transactionInfo
properties
length = uint16(0);
queueID = uint8(0);
delay = uint64(0);
end
methods
function obj = queueInfo(v)
if nargin > 0
obj.length = uint16(v);
obj.queueID = uint8(v);
obj.delay = uint64(v);
end
end
end
end
Does anyone know how to fix this issue?
Note: There might be some obvious errors in my class structures, I am kind of new to OOP. Every suggestion is welcomed.Hello,
I am trying to built a Simulink function which keeps record of the statistics of the system by using array of classes. However, I can not generate an array of class in Simulink. I realize that I should instantiate an array in Simulink but how can I instantiate a class?
arrivedArray(3, 65536) = queueInfo;
analysisArray(3, 65536) = queueInfo;
In the picture above, queueInfo is my class. This two lines return with the following error.
Code generation requires variable arrivedArray to be fully defined before subscribing it.
By the way, this is the suggested method by Matlab for creating an array of class but somehow it doesn’t work. Later I’ve tried this one:
persistent arrivedArray
if isempty(arrivedArray)
arrivedArray(3, 655336) = queueInfo;
end
persistent analysisArray
if isempty(analysisArray)
analysisArray(3, 65536) = queueInfo;
end
But it doesn’t work either. The error İs:
Persistent variable ‘arrivedArray’ must be assigned before it is used. The only exception is a check using ‘isempty(arrivedArray)’ that can be performed prior to assignment.
I understand the error but have no idea how to fix it. A constructor did not help me too. Here is my class structure:
1
classdef transactionInfo
properties
tag = uint16(0);
arrivalTime = uint64(0);
departureTime = uint64(0);
end
methods
function obj = transactionInfo(v)
if nargin > 0
obj.tag = uint16(v);
obj.arrivalTime = uint64(v);
obj.departureTime = uint64(v);
end
end
end
end
2
classdef queueInfo < transactionInfo
properties
length = uint16(0);
queueID = uint8(0);
delay = uint64(0);
end
methods
function obj = queueInfo(v)
if nargin > 0
obj.length = uint16(v);
obj.queueID = uint8(v);
obj.delay = uint64(v);
end
end
end
end
Does anyone know how to fix this issue?
Note: There might be some obvious errors in my class structures, I am kind of new to OOP. Every suggestion is welcomed. Hello,
I am trying to built a Simulink function which keeps record of the statistics of the system by using array of classes. However, I can not generate an array of class in Simulink. I realize that I should instantiate an array in Simulink but how can I instantiate a class?
arrivedArray(3, 65536) = queueInfo;
analysisArray(3, 65536) = queueInfo;
In the picture above, queueInfo is my class. This two lines return with the following error.
Code generation requires variable arrivedArray to be fully defined before subscribing it.
By the way, this is the suggested method by Matlab for creating an array of class but somehow it doesn’t work. Later I’ve tried this one:
persistent arrivedArray
if isempty(arrivedArray)
arrivedArray(3, 655336) = queueInfo;
end
persistent analysisArray
if isempty(analysisArray)
analysisArray(3, 65536) = queueInfo;
end
But it doesn’t work either. The error İs:
Persistent variable ‘arrivedArray’ must be assigned before it is used. The only exception is a check using ‘isempty(arrivedArray)’ that can be performed prior to assignment.
I understand the error but have no idea how to fix it. A constructor did not help me too. Here is my class structure:
1
classdef transactionInfo
properties
tag = uint16(0);
arrivalTime = uint64(0);
departureTime = uint64(0);
end
methods
function obj = transactionInfo(v)
if nargin > 0
obj.tag = uint16(v);
obj.arrivalTime = uint64(v);
obj.departureTime = uint64(v);
end
end
end
end
2
classdef queueInfo < transactionInfo
properties
length = uint16(0);
queueID = uint8(0);
delay = uint64(0);
end
methods
function obj = queueInfo(v)
if nargin > 0
obj.length = uint16(v);
obj.queueID = uint8(v);
obj.delay = uint64(v);
end
end
end
end
Does anyone know how to fix this issue?
Note: There might be some obvious errors in my class structures, I am kind of new to OOP. Every suggestion is welcomed. simulink, class, code generation MATLAB Answers — New Questions
How can I count the number of non virtual blocks in my model?
I have a home licenseI have a home license I have a home license non virtual MATLAB Answers — New Questions