Tag Archives: matlab
I am trying to use matlab with refprop, but it shows [SETUP error 101] error in opening file for component # 1; filename = (C:Program Files (x86)REFPROPfluidsfluid.fld).
fluid=’cyclopentane’
T1=348.15;
P1=refpropm(‘P’,’T’,T1,’Q’,1,’fluid’);fluid=’cyclopentane’
T1=348.15;
P1=refpropm(‘P’,’T’,T1,’Q’,1,’fluid’); fluid=’cyclopentane’
T1=348.15;
P1=refpropm(‘P’,’T’,T1,’Q’,1,’fluid’); refprop, [setup error 101] MATLAB Answers — New Questions
How to resolve unsupported functions in MATLAB HDL Coder?
Hello,
We have some simulation code written in MATLAB that we are trying to simulate and deploy on an FPGA, and so we are trying to use the HDL Coder tool for this task. However, we are receiving code generation issues indicating that the following functions are not supported:
diff
fft
exp
angle
ifft
filter
Is there perhaps a toolkit or package that replicates these functions with support for HDL coding? I tried referencing the list of supported functions found here:
https://www.mathworks.com/help/hdlcoder/ug/functions-supported-for-hdl-code-generation-alphabetical-list.html
But the links for supported functions don’t seem to be working (at least for me).
Otherwise, is there a recommended way of resolving this?
Thank you,
James
P.S. I have successfully used the MATLAB Coder to generate C code for this project, if this helps.Hello,
We have some simulation code written in MATLAB that we are trying to simulate and deploy on an FPGA, and so we are trying to use the HDL Coder tool for this task. However, we are receiving code generation issues indicating that the following functions are not supported:
diff
fft
exp
angle
ifft
filter
Is there perhaps a toolkit or package that replicates these functions with support for HDL coding? I tried referencing the list of supported functions found here:
https://www.mathworks.com/help/hdlcoder/ug/functions-supported-for-hdl-code-generation-alphabetical-list.html
But the links for supported functions don’t seem to be working (at least for me).
Otherwise, is there a recommended way of resolving this?
Thank you,
James
P.S. I have successfully used the MATLAB Coder to generate C code for this project, if this helps. Hello,
We have some simulation code written in MATLAB that we are trying to simulate and deploy on an FPGA, and so we are trying to use the HDL Coder tool for this task. However, we are receiving code generation issues indicating that the following functions are not supported:
diff
fft
exp
angle
ifft
filter
Is there perhaps a toolkit or package that replicates these functions with support for HDL coding? I tried referencing the list of supported functions found here:
https://www.mathworks.com/help/hdlcoder/ug/functions-supported-for-hdl-code-generation-alphabetical-list.html
But the links for supported functions don’t seem to be working (at least for me).
Otherwise, is there a recommended way of resolving this?
Thank you,
James
P.S. I have successfully used the MATLAB Coder to generate C code for this project, if this helps. fft, matlab code MATLAB Answers — New Questions
FGETL taking a long time to execute
I am running fgetl in a loop similar to the code below. When profiling the code, I noticed that fgetl(fid) takes the most time to execute compared to the rest of the code. After checking the fgetl documentation, I found the following note in the documentation:
fgetl is intended for use with files that contain newline characters. Given a file with no newline characters, fgetl may take a long time to execute.
However, the documentation does not provide a solution for files without newline characters. Since my file lacks newline characters, what would be the best alternative to fgetl?
fid = fopen(FileName);
while ischar(tline) %loops over 1e5 times
% read new line
tic
tline = fgetl(fid);
toc
% Do stuff with tline
endI am running fgetl in a loop similar to the code below. When profiling the code, I noticed that fgetl(fid) takes the most time to execute compared to the rest of the code. After checking the fgetl documentation, I found the following note in the documentation:
fgetl is intended for use with files that contain newline characters. Given a file with no newline characters, fgetl may take a long time to execute.
However, the documentation does not provide a solution for files without newline characters. Since my file lacks newline characters, what would be the best alternative to fgetl?
fid = fopen(FileName);
while ischar(tline) %loops over 1e5 times
% read new line
tic
tline = fgetl(fid);
toc
% Do stuff with tline
end I am running fgetl in a loop similar to the code below. When profiling the code, I noticed that fgetl(fid) takes the most time to execute compared to the rest of the code. After checking the fgetl documentation, I found the following note in the documentation:
fgetl is intended for use with files that contain newline characters. Given a file with no newline characters, fgetl may take a long time to execute.
However, the documentation does not provide a solution for files without newline characters. Since my file lacks newline characters, what would be the best alternative to fgetl?
fid = fopen(FileName);
while ischar(tline) %loops over 1e5 times
% read new line
tic
tline = fgetl(fid);
toc
% Do stuff with tline
end fgetl, fgets, loop MATLAB Answers — New Questions
Increase the plotting performance in the MATLAB level (drawmode/ optimizing rendering/ down sampling etc)
*Problem statement*: Increase the plotting performance in the MATLAB level (drawmode/ optimizing rendering/ down sampling etc)
*Background*: We are working on a MATLAB based framework for analysis and visualization of data. The information that we use for plotting is very huge. The number of data points are in the range of ~10E7 or more and we are facing MATLAB performance issues when we zoom/pan/maximize/minimize. We urgently need to improve the performance. The requirement is to have the complete information in the plot but the end user chooses to enable or disable particular lines based on the need. As a framework owner we do not have any control on the number of data points that are used for the plot or remove the overlapping points.
Bottom line is we cannot modify the data to be plotted so we will continue to have huge number of points. We can only try from the MATLAB layer to increase the performance as requested above.
Please help us to improve the performance with your experience.
Looking forward for your answers.
Thanks,
Dhanya*Problem statement*: Increase the plotting performance in the MATLAB level (drawmode/ optimizing rendering/ down sampling etc)
*Background*: We are working on a MATLAB based framework for analysis and visualization of data. The information that we use for plotting is very huge. The number of data points are in the range of ~10E7 or more and we are facing MATLAB performance issues when we zoom/pan/maximize/minimize. We urgently need to improve the performance. The requirement is to have the complete information in the plot but the end user chooses to enable or disable particular lines based on the need. As a framework owner we do not have any control on the number of data points that are used for the plot or remove the overlapping points.
Bottom line is we cannot modify the data to be plotted so we will continue to have huge number of points. We can only try from the MATLAB layer to increase the performance as requested above.
Please help us to improve the performance with your experience.
Looking forward for your answers.
Thanks,
Dhanya *Problem statement*: Increase the plotting performance in the MATLAB level (drawmode/ optimizing rendering/ down sampling etc)
*Background*: We are working on a MATLAB based framework for analysis and visualization of data. The information that we use for plotting is very huge. The number of data points are in the range of ~10E7 or more and we are facing MATLAB performance issues when we zoom/pan/maximize/minimize. We urgently need to improve the performance. The requirement is to have the complete information in the plot but the end user chooses to enable or disable particular lines based on the need. As a framework owner we do not have any control on the number of data points that are used for the plot or remove the overlapping points.
Bottom line is we cannot modify the data to be plotted so we will continue to have huge number of points. We can only try from the MATLAB layer to increase the performance as requested above.
Please help us to improve the performance with your experience.
Looking forward for your answers.
Thanks,
Dhanya matlab plot performance, performance, hg1, hg2 MATLAB Answers — New Questions
How to simulate permanent magnets using the PDE Toolbox in R2025a
I am trying to model and visualize two permanent magnet spheres using the below code snippet:
function twoMagnets_femodel_demo()
clc; clear; close all;
% ——————————-
% 1) Define geometry parameters
% ——————————-
% Let’s assume "1/2-inch magnets" => diameter = 0.5 inch => radius = 0.25 in
% 1 inch ~ 0.0254 m, so 0.25 in ~ 0.00635 m
R_sphere = 0.00635; % [m]
% Bounding box of ~5 cm each side
boxDim = 0.05; % [m]
% ——————————-
% 2) Build geometry parts
% ——————————-
% (a) Air region: bounding box
boxGm = multicuboid(boxDim, boxDim, boxDim);
% (b) Sphere #1
sphere1Gm = multisphere(R_sphere);
% (c) Sphere #2
sphere2Gm = multisphere(R_sphere);
% Translate spheres so that they’re centered in the box, side-by-side
% Let the box corners go from (0,0,0) to (0.05,0.05,0.05), so center ~ (0.025,0.025,0.025)
centerBox = [0.025, 0.025, 0.025];
offset1 = centerBox + [-R_sphere, 0, 0]; % shift left in x
offset2 = centerBox + [ R_sphere, 0, 0]; % shift right in x
sphere1Gm = translate(sphere1Gm, offset1);
sphere2Gm = translate(sphere2Gm, offset2);
% ——————————-
% 3) Combine geometries
% ——————————-
% addCell(…) is the new PDE Toolbox function that
% keeps each shape as a separate "cell" in the final geometry.
gm = addCell(boxGm, sphere1Gm);
gm = addCell(gm, sphere2Gm);
% Visualize & label
figure;
pdegplot(gm, FaceAlpha=0.2, CellLabels="on");
title("Bounding Box + Two Spheres");
axis equal
% At this point we should see "Cell #1 = bounding box, #2 = first sphere, #3 = second sphere"
% ——————————-
% 4) Create femodel for magnetostatics
% ——————————-
model = femodel(AnalysisType="magnetostatic", Geometry=gm);
% Specify vacuum permeability in SI (H/m)
model.VacuumPermeability = 4*pi*1e-7; % ~ 1.2566370614e-6
% ——————————-
% 5) Set material properties
% ——————————-
% We have 3 cells:
% 1 => bounding box (air)
% 2 => sphere #1
% 3 => sphere #2
%
% For air and the spheres, assume relative permeability ~ 1
model.MaterialProperties(1) = materialProperties(RelativePermeability=1);
model.MaterialProperties(2) = materialProperties(RelativePermeability=1);
model.MaterialProperties(3) = materialProperties(RelativePermeability=1);
% ——————————-
% 6) Assign magnetization
% ——————————-
% In new PDE Toolbox, you can set magnetization on the "CellLoad" for a subdomain (cell).
% Suppose sphere #1 is magnetized in +z; sphere #2 in -z.
% For a typical neodymium magnet, you might set M ~ 1e5 or 1e6 A/m.
M1 = [0; 0; 1e5];
M2 = [0; 0;-1e5];
model.CellLoad(2) = cellLoad(Magnetization=M1); % sphere1
model.CellLoad(3) = cellLoad(Magnetization=M2); % sphere2
% ——————————-
% 7) Boundary conditions
% ——————————-
% Typically, you’d set a "zero" magnetic potential (A = 0) on the outer faces
% of the bounding box to approximate an open boundary.
% Identify the face IDs of the bounding box:
% pdegplot(gm, FaceAlpha=0.1, CellLabels="on", FaceLabels="on")
% The bounding box typically has 6 faces with IDs [1..6].
% So we do:
model.FaceBC(1:6) = faceBC(MagneticPotential=[0;0;0]);
% (If you find different face numbering, adjust accordingly.)
% ——————————-
% 8) Generate mesh
% ——————————-
% We can specify "Hcell" to refine the mesh in certain cells, e.g. the magnets,
% or keep it uniform. For example, refine in cells 2 & 3 (the spheres):
internalCells = [2 3];
model = generateMesh(model, Hcell={internalCells, R_sphere/3});
% ——————————-
% 9) Solve
% ——————————-
R = solve(model);
% R is a MagnetostaticResults object with fields:
% R.MagneticPotential, R.MagneticField, R.MagneticFluxDensity, R.Mesh, etc.
% ——————————-
% 10) Postprocessing
% ——————————-
% Extract Bx, By, Bz at the mesh nodes
Bx = R.MagneticFluxDensity.Bx;
By = R.MagneticFluxDensity.By;
Bz = R.MagneticFluxDensity.Bz;
Bmag = sqrt(Bx.^2 + By.^2 + Bz.^2);
% Simple 3D plot of |B|
figure;
pdeplot3D(R.Mesh, ColorMapData=Bmag);
title("|B| flux density magnitude");
colorbar;
% Optionally, a vector plot:
figure;
pdeplot3D(R.Mesh, FlowData=[Bx By Bz]);
title("Magnetic Field Vectors");
end
While logically complete, the above code doesn’t work. The current error I am struggling with is that addCell() only works inside the original geometry. And throws the following error here:
Error using pde.DiscreteGeometry/addCell
Added cells must be located strictly inside a single cell of the original geometry.
Error in
TwoMagnets (line 38)
gm = addCell(boxGm, sphere1Gm);
^^^^^^^^^^^^^^^^^^^^^^^^^
Is there an example script on how to simulate permanent magnets using the latest PDE Toolbox?I am trying to model and visualize two permanent magnet spheres using the below code snippet:
function twoMagnets_femodel_demo()
clc; clear; close all;
% ——————————-
% 1) Define geometry parameters
% ——————————-
% Let’s assume "1/2-inch magnets" => diameter = 0.5 inch => radius = 0.25 in
% 1 inch ~ 0.0254 m, so 0.25 in ~ 0.00635 m
R_sphere = 0.00635; % [m]
% Bounding box of ~5 cm each side
boxDim = 0.05; % [m]
% ——————————-
% 2) Build geometry parts
% ——————————-
% (a) Air region: bounding box
boxGm = multicuboid(boxDim, boxDim, boxDim);
% (b) Sphere #1
sphere1Gm = multisphere(R_sphere);
% (c) Sphere #2
sphere2Gm = multisphere(R_sphere);
% Translate spheres so that they’re centered in the box, side-by-side
% Let the box corners go from (0,0,0) to (0.05,0.05,0.05), so center ~ (0.025,0.025,0.025)
centerBox = [0.025, 0.025, 0.025];
offset1 = centerBox + [-R_sphere, 0, 0]; % shift left in x
offset2 = centerBox + [ R_sphere, 0, 0]; % shift right in x
sphere1Gm = translate(sphere1Gm, offset1);
sphere2Gm = translate(sphere2Gm, offset2);
% ——————————-
% 3) Combine geometries
% ——————————-
% addCell(…) is the new PDE Toolbox function that
% keeps each shape as a separate "cell" in the final geometry.
gm = addCell(boxGm, sphere1Gm);
gm = addCell(gm, sphere2Gm);
% Visualize & label
figure;
pdegplot(gm, FaceAlpha=0.2, CellLabels="on");
title("Bounding Box + Two Spheres");
axis equal
% At this point we should see "Cell #1 = bounding box, #2 = first sphere, #3 = second sphere"
% ——————————-
% 4) Create femodel for magnetostatics
% ——————————-
model = femodel(AnalysisType="magnetostatic", Geometry=gm);
% Specify vacuum permeability in SI (H/m)
model.VacuumPermeability = 4*pi*1e-7; % ~ 1.2566370614e-6
% ——————————-
% 5) Set material properties
% ——————————-
% We have 3 cells:
% 1 => bounding box (air)
% 2 => sphere #1
% 3 => sphere #2
%
% For air and the spheres, assume relative permeability ~ 1
model.MaterialProperties(1) = materialProperties(RelativePermeability=1);
model.MaterialProperties(2) = materialProperties(RelativePermeability=1);
model.MaterialProperties(3) = materialProperties(RelativePermeability=1);
% ——————————-
% 6) Assign magnetization
% ——————————-
% In new PDE Toolbox, you can set magnetization on the "CellLoad" for a subdomain (cell).
% Suppose sphere #1 is magnetized in +z; sphere #2 in -z.
% For a typical neodymium magnet, you might set M ~ 1e5 or 1e6 A/m.
M1 = [0; 0; 1e5];
M2 = [0; 0;-1e5];
model.CellLoad(2) = cellLoad(Magnetization=M1); % sphere1
model.CellLoad(3) = cellLoad(Magnetization=M2); % sphere2
% ——————————-
% 7) Boundary conditions
% ——————————-
% Typically, you’d set a "zero" magnetic potential (A = 0) on the outer faces
% of the bounding box to approximate an open boundary.
% Identify the face IDs of the bounding box:
% pdegplot(gm, FaceAlpha=0.1, CellLabels="on", FaceLabels="on")
% The bounding box typically has 6 faces with IDs [1..6].
% So we do:
model.FaceBC(1:6) = faceBC(MagneticPotential=[0;0;0]);
% (If you find different face numbering, adjust accordingly.)
% ——————————-
% 8) Generate mesh
% ——————————-
% We can specify "Hcell" to refine the mesh in certain cells, e.g. the magnets,
% or keep it uniform. For example, refine in cells 2 & 3 (the spheres):
internalCells = [2 3];
model = generateMesh(model, Hcell={internalCells, R_sphere/3});
% ——————————-
% 9) Solve
% ——————————-
R = solve(model);
% R is a MagnetostaticResults object with fields:
% R.MagneticPotential, R.MagneticField, R.MagneticFluxDensity, R.Mesh, etc.
% ——————————-
% 10) Postprocessing
% ——————————-
% Extract Bx, By, Bz at the mesh nodes
Bx = R.MagneticFluxDensity.Bx;
By = R.MagneticFluxDensity.By;
Bz = R.MagneticFluxDensity.Bz;
Bmag = sqrt(Bx.^2 + By.^2 + Bz.^2);
% Simple 3D plot of |B|
figure;
pdeplot3D(R.Mesh, ColorMapData=Bmag);
title("|B| flux density magnitude");
colorbar;
% Optionally, a vector plot:
figure;
pdeplot3D(R.Mesh, FlowData=[Bx By Bz]);
title("Magnetic Field Vectors");
end
While logically complete, the above code doesn’t work. The current error I am struggling with is that addCell() only works inside the original geometry. And throws the following error here:
Error using pde.DiscreteGeometry/addCell
Added cells must be located strictly inside a single cell of the original geometry.
Error in
TwoMagnets (line 38)
gm = addCell(boxGm, sphere1Gm);
^^^^^^^^^^^^^^^^^^^^^^^^^
Is there an example script on how to simulate permanent magnets using the latest PDE Toolbox? I am trying to model and visualize two permanent magnet spheres using the below code snippet:
function twoMagnets_femodel_demo()
clc; clear; close all;
% ——————————-
% 1) Define geometry parameters
% ——————————-
% Let’s assume "1/2-inch magnets" => diameter = 0.5 inch => radius = 0.25 in
% 1 inch ~ 0.0254 m, so 0.25 in ~ 0.00635 m
R_sphere = 0.00635; % [m]
% Bounding box of ~5 cm each side
boxDim = 0.05; % [m]
% ——————————-
% 2) Build geometry parts
% ——————————-
% (a) Air region: bounding box
boxGm = multicuboid(boxDim, boxDim, boxDim);
% (b) Sphere #1
sphere1Gm = multisphere(R_sphere);
% (c) Sphere #2
sphere2Gm = multisphere(R_sphere);
% Translate spheres so that they’re centered in the box, side-by-side
% Let the box corners go from (0,0,0) to (0.05,0.05,0.05), so center ~ (0.025,0.025,0.025)
centerBox = [0.025, 0.025, 0.025];
offset1 = centerBox + [-R_sphere, 0, 0]; % shift left in x
offset2 = centerBox + [ R_sphere, 0, 0]; % shift right in x
sphere1Gm = translate(sphere1Gm, offset1);
sphere2Gm = translate(sphere2Gm, offset2);
% ——————————-
% 3) Combine geometries
% ——————————-
% addCell(…) is the new PDE Toolbox function that
% keeps each shape as a separate "cell" in the final geometry.
gm = addCell(boxGm, sphere1Gm);
gm = addCell(gm, sphere2Gm);
% Visualize & label
figure;
pdegplot(gm, FaceAlpha=0.2, CellLabels="on");
title("Bounding Box + Two Spheres");
axis equal
% At this point we should see "Cell #1 = bounding box, #2 = first sphere, #3 = second sphere"
% ——————————-
% 4) Create femodel for magnetostatics
% ——————————-
model = femodel(AnalysisType="magnetostatic", Geometry=gm);
% Specify vacuum permeability in SI (H/m)
model.VacuumPermeability = 4*pi*1e-7; % ~ 1.2566370614e-6
% ——————————-
% 5) Set material properties
% ——————————-
% We have 3 cells:
% 1 => bounding box (air)
% 2 => sphere #1
% 3 => sphere #2
%
% For air and the spheres, assume relative permeability ~ 1
model.MaterialProperties(1) = materialProperties(RelativePermeability=1);
model.MaterialProperties(2) = materialProperties(RelativePermeability=1);
model.MaterialProperties(3) = materialProperties(RelativePermeability=1);
% ——————————-
% 6) Assign magnetization
% ——————————-
% In new PDE Toolbox, you can set magnetization on the "CellLoad" for a subdomain (cell).
% Suppose sphere #1 is magnetized in +z; sphere #2 in -z.
% For a typical neodymium magnet, you might set M ~ 1e5 or 1e6 A/m.
M1 = [0; 0; 1e5];
M2 = [0; 0;-1e5];
model.CellLoad(2) = cellLoad(Magnetization=M1); % sphere1
model.CellLoad(3) = cellLoad(Magnetization=M2); % sphere2
% ——————————-
% 7) Boundary conditions
% ——————————-
% Typically, you’d set a "zero" magnetic potential (A = 0) on the outer faces
% of the bounding box to approximate an open boundary.
% Identify the face IDs of the bounding box:
% pdegplot(gm, FaceAlpha=0.1, CellLabels="on", FaceLabels="on")
% The bounding box typically has 6 faces with IDs [1..6].
% So we do:
model.FaceBC(1:6) = faceBC(MagneticPotential=[0;0;0]);
% (If you find different face numbering, adjust accordingly.)
% ——————————-
% 8) Generate mesh
% ——————————-
% We can specify "Hcell" to refine the mesh in certain cells, e.g. the magnets,
% or keep it uniform. For example, refine in cells 2 & 3 (the spheres):
internalCells = [2 3];
model = generateMesh(model, Hcell={internalCells, R_sphere/3});
% ——————————-
% 9) Solve
% ——————————-
R = solve(model);
% R is a MagnetostaticResults object with fields:
% R.MagneticPotential, R.MagneticField, R.MagneticFluxDensity, R.Mesh, etc.
% ——————————-
% 10) Postprocessing
% ——————————-
% Extract Bx, By, Bz at the mesh nodes
Bx = R.MagneticFluxDensity.Bx;
By = R.MagneticFluxDensity.By;
Bz = R.MagneticFluxDensity.Bz;
Bmag = sqrt(Bx.^2 + By.^2 + Bz.^2);
% Simple 3D plot of |B|
figure;
pdeplot3D(R.Mesh, ColorMapData=Bmag);
title("|B| flux density magnitude");
colorbar;
% Optionally, a vector plot:
figure;
pdeplot3D(R.Mesh, FlowData=[Bx By Bz]);
title("Magnetic Field Vectors");
end
While logically complete, the above code doesn’t work. The current error I am struggling with is that addCell() only works inside the original geometry. And throws the following error here:
Error using pde.DiscreteGeometry/addCell
Added cells must be located strictly inside a single cell of the original geometry.
Error in
TwoMagnets (line 38)
gm = addCell(boxGm, sphere1Gm);
^^^^^^^^^^^^^^^^^^^^^^^^^
Is there an example script on how to simulate permanent magnets using the latest PDE Toolbox? pde, matlab code, mesh MATLAB Answers — New Questions
How can I plot multiple figures in one from multiple saved .fig files that have 2 figures but I only want 1 of them?
I have run multiple simulations of a system and in each run I changed one parameter. I saved the .fig files of a scope I am interested in but the scope plots 2 figures separated by the layout function (so there is one on top and one on the bottom part when you click/view the scope). How can I plot only the top figure (1st input in the scope) from the various .fig files that I saved? I want to highlight the difference when I change a specific parameter (increase and decrease) and repeat for each parameter that I changed.
Thank you a lot in advance!I have run multiple simulations of a system and in each run I changed one parameter. I saved the .fig files of a scope I am interested in but the scope plots 2 figures separated by the layout function (so there is one on top and one on the bottom part when you click/view the scope). How can I plot only the top figure (1st input in the scope) from the various .fig files that I saved? I want to highlight the difference when I change a specific parameter (increase and decrease) and repeat for each parameter that I changed.
Thank you a lot in advance! I have run multiple simulations of a system and in each run I changed one parameter. I saved the .fig files of a scope I am interested in but the scope plots 2 figures separated by the layout function (so there is one on top and one on the bottom part when you click/view the scope). How can I plot only the top figure (1st input in the scope) from the various .fig files that I saved? I want to highlight the difference when I change a specific parameter (increase and decrease) and repeat for each parameter that I changed.
Thank you a lot in advance! matlab, simulink, figure MATLAB Answers — New Questions
Characterize RC parameters of a battery cell.
Hi,
I want to extract RC values from HPPC test, and I found a good example on MathWorks:Characterize Battery Cell for Electric Vehicles, However I can find batt_BatteryCellCharacterization function, is there anything I need to do?Hi,
I want to extract RC values from HPPC test, and I found a good example on MathWorks:Characterize Battery Cell for Electric Vehicles, However I can find batt_BatteryCellCharacterization function, is there anything I need to do? Hi,
I want to extract RC values from HPPC test, and I found a good example on MathWorks:Characterize Battery Cell for Electric Vehicles, However I can find batt_BatteryCellCharacterization function, is there anything I need to do? battery, modelling MATLAB Answers — New Questions
multiplicationLayer – multiply by a constant
I’m trying to implement a neural net in which a layer multiplies every input by a constant. There is a multiplicationLayer net in the Deep Learning Toolbox which can have any number of inputs, but I cannot connect one of those inputs to a constant of any type.
TIA!I’m trying to implement a neural net in which a layer multiplies every input by a constant. There is a multiplicationLayer net in the Deep Learning Toolbox which can have any number of inputs, but I cannot connect one of those inputs to a constant of any type.
TIA! I’m trying to implement a neural net in which a layer multiplies every input by a constant. There is a multiplicationLayer net in the Deep Learning Toolbox which can have any number of inputs, but I cannot connect one of those inputs to a constant of any type.
TIA! multiplicationlayer MATLAB Answers — New Questions
Running/testing scripts on multiple Matlab/Simulink versions?
I do a lot of script and tool development for Matlab/Simulink. This involves supporting multiple versions of Matlab, usually from R2016a+ (previously it was R2011b+). This means that I have almost a dozen different versions of Matlab installed on my computer. When one of my tools/scripts encounters a bug in a version of Matlab, or the Matlab/Simulink behaviour differs between versions, I need to be able to pinpoint which version the bug occurred in or the behaviour changed in. I usually can’t find the bugs listed on the Bug Reports support page, especially when the bugs are already fixed in later versions. Likewise, when the behaviour changes I check if it is noted in the Release Notes, but these are very high-level descriptions and I usually can’t find it mentioned.
Given that the aforementioned pages are not reliable, I usually need to figure out which version of Matlab has the bug fix or behaviour change. I typically follow this process:
I create a script to replicate the bug automatically (if possible).
One by one I open each version of Matlab, execute the script, and make note of when the bug occurs. Sometimes I have to download and install additional Matlab versions.
Then I develop a workaround for the bug or behaviour change by having the script check which version it is running on, and then perform extra steps to fix the buggy behavior or accommodate for inconsistent behaviours between the versions.
My questions is: Is it possible run a script on multiple versions of Matlab in order to make this process a little easier?I do a lot of script and tool development for Matlab/Simulink. This involves supporting multiple versions of Matlab, usually from R2016a+ (previously it was R2011b+). This means that I have almost a dozen different versions of Matlab installed on my computer. When one of my tools/scripts encounters a bug in a version of Matlab, or the Matlab/Simulink behaviour differs between versions, I need to be able to pinpoint which version the bug occurred in or the behaviour changed in. I usually can’t find the bugs listed on the Bug Reports support page, especially when the bugs are already fixed in later versions. Likewise, when the behaviour changes I check if it is noted in the Release Notes, but these are very high-level descriptions and I usually can’t find it mentioned.
Given that the aforementioned pages are not reliable, I usually need to figure out which version of Matlab has the bug fix or behaviour change. I typically follow this process:
I create a script to replicate the bug automatically (if possible).
One by one I open each version of Matlab, execute the script, and make note of when the bug occurs. Sometimes I have to download and install additional Matlab versions.
Then I develop a workaround for the bug or behaviour change by having the script check which version it is running on, and then perform extra steps to fix the buggy behavior or accommodate for inconsistent behaviours between the versions.
My questions is: Is it possible run a script on multiple versions of Matlab in order to make this process a little easier? I do a lot of script and tool development for Matlab/Simulink. This involves supporting multiple versions of Matlab, usually from R2016a+ (previously it was R2011b+). This means that I have almost a dozen different versions of Matlab installed on my computer. When one of my tools/scripts encounters a bug in a version of Matlab, or the Matlab/Simulink behaviour differs between versions, I need to be able to pinpoint which version the bug occurred in or the behaviour changed in. I usually can’t find the bugs listed on the Bug Reports support page, especially when the bugs are already fixed in later versions. Likewise, when the behaviour changes I check if it is noted in the Release Notes, but these are very high-level descriptions and I usually can’t find it mentioned.
Given that the aforementioned pages are not reliable, I usually need to figure out which version of Matlab has the bug fix or behaviour change. I typically follow this process:
I create a script to replicate the bug automatically (if possible).
One by one I open each version of Matlab, execute the script, and make note of when the bug occurs. Sometimes I have to download and install additional Matlab versions.
Then I develop a workaround for the bug or behaviour change by having the script check which version it is running on, and then perform extra steps to fix the buggy behavior or accommodate for inconsistent behaviours between the versions.
My questions is: Is it possible run a script on multiple versions of Matlab in order to make this process a little easier? version, bugs, release notes, bug reports MATLAB Answers — New Questions
Concatenation Error when using LSTM Layers in a Hybrid Actor (RL Toolbox)
Hey,
Unfortunately, I run into a concatenation error when I try to use LSTM layers combined with a hybrid actor in my RL framework. There would be an easy way to fix that in the sequenceExperienceArray.m file from the RL toolbox, however, I cannot save the changes because I get the error "Access denied".
Did anyone else experience this and found a workaround?
Thanks!Hey,
Unfortunately, I run into a concatenation error when I try to use LSTM layers combined with a hybrid actor in my RL framework. There would be an easy way to fix that in the sequenceExperienceArray.m file from the RL toolbox, however, I cannot save the changes because I get the error "Access denied".
Did anyone else experience this and found a workaround?
Thanks! Hey,
Unfortunately, I run into a concatenation error when I try to use LSTM layers combined with a hybrid actor in my RL framework. There would be an easy way to fix that in the sequenceExperienceArray.m file from the RL toolbox, however, I cannot save the changes because I get the error "Access denied".
Did anyone else experience this and found a workaround?
Thanks! rl-toolbox, lstm, concatenation MATLAB Answers — New Questions
Problem while running setup of Raspberry Pi Support Package
Hi Matlabers,
I am trying to install the Rapbian imager for matlab, and while configuring my hardware in the process, i get the following error:
"cannot retrieve removable drives: ‘wmic’ is not recognized as an internal or external command, operable program or batch file"
I saw a question like this here before but the solution there wasn’t good for me.
I added the following to my Path
%SystemRoot%System32Wbem
but no good.
Please help!Hi Matlabers,
I am trying to install the Rapbian imager for matlab, and while configuring my hardware in the process, i get the following error:
"cannot retrieve removable drives: ‘wmic’ is not recognized as an internal or external command, operable program or batch file"
I saw a question like this here before but the solution there wasn’t good for me.
I added the following to my Path
%SystemRoot%System32Wbem
but no good.
Please help! Hi Matlabers,
I am trying to install the Rapbian imager for matlab, and while configuring my hardware in the process, i get the following error:
"cannot retrieve removable drives: ‘wmic’ is not recognized as an internal or external command, operable program or batch file"
I saw a question like this here before but the solution there wasn’t good for me.
I added the following to my Path
%SystemRoot%System32Wbem
but no good.
Please help! raspberry pi, system, path, packages, installation MATLAB Answers — New Questions
Update the content of a MatLab generated executable
I would like to update the content of an executable inside a generated executable MatLab file. The file is generated with MatLab/Simulink compiler. Why would I want to do this? Because I need to sign the content of all executable that run on my company pc. I know I can open the generated executable as a zip file. Inside I can update or add any file.
I have found that there is a sig1.xml file that contains the sha512 encoded with base64. So I have updated the sha512 signature of the modified file. But I have an error when opening the executable: CTF archive is invalid
Is there a global signature to update? Or anything else?
Any advice is welcome!I would like to update the content of an executable inside a generated executable MatLab file. The file is generated with MatLab/Simulink compiler. Why would I want to do this? Because I need to sign the content of all executable that run on my company pc. I know I can open the generated executable as a zip file. Inside I can update or add any file.
I have found that there is a sig1.xml file that contains the sha512 encoded with base64. So I have updated the sha512 signature of the modified file. But I have an error when opening the executable: CTF archive is invalid
Is there a global signature to update? Or anything else?
Any advice is welcome! I would like to update the content of an executable inside a generated executable MatLab file. The file is generated with MatLab/Simulink compiler. Why would I want to do this? Because I need to sign the content of all executable that run on my company pc. I know I can open the generated executable as a zip file. Inside I can update or add any file.
I have found that there is a sig1.xml file that contains the sha512 encoded with base64. So I have updated the sha512 signature of the modified file. But I have an error when opening the executable: CTF archive is invalid
Is there a global signature to update? Or anything else?
Any advice is welcome! matlab MATLAB Answers — New Questions
How to solve system of PDE’s using crank nicolson method to get graphical interpretations of equations? How to get skin friction and nusselt number using this code?
i have attached my matlb code for solving system of PDE ∂u/∂t=(∂^2 u)/〖∂η〗^2 +α (∂^3 u)/〖∂η〗^3 +δcφ+Grθ-Mu
∂θ/∂t=1/Pr (∂^2 θ)/〖∂η〗^2 +D_f (∂^2 φ)/〖∂η〗^2
∂φ/∂t=1/S_c (∂^2 φ)/〖∂η〗^2 +S_r (∂^2 θ)/〖∂η〗^2
when η→0
when η→0:u=sin(wt),θ=1 ,φ=1
when η→∞:u→0,θ→0,φ→0
But,i’m confused how to set boundary conditions in this code. Also i want to set these skin friction and nusselt number expressions: C_f=-(∂u/∂η) at η=0
Nu〖Re〗_x^(-1)=-(∂θ/∂η) at η=0
in this code;
function yy= crank
n=105;
h=0.01;
m=0.1;
B=0; %B=0.0001;
Gr=2; %Gr=0.1=Delt. Gs=Dels
A=2; %A=alpha
Pr=5;
Gs=1; %3.5
Sc=1.5;
M=9; %M=30,12
Df=5;
Sr=10;
Ec=0.1; % 0.01-0.1(0-1)
t(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p(-t(j-1)))-Df*(1/2*h^2)*(exp(-t(j+1))-2* exp(-t(j))…
+exp(-t(j-1)))+(bb(j,k)/h)-(1/2*Pr*h^2)*(bb(j+1,k)-2*bb(j,k)+bb(j-1,k))-(Df/2*h^2)*(cc(j+1,k)-2*cc(j,k)+cc(j-1,k));
r3(j,k)=-(exp((-t(j)))/h)-(1/2*Sc*h^2)*(exp(-t(j+1))-2*exp(-t(j))+exp(-t(j-1)))-(Sr/2*h^2)*(exp(-t(j+1))-2*exp(-t(j))+exp(-t(j-1)))+ (cc(j,k)/h)…
-(1/2*Sc*h^2)*(cc(j+1,k)-2*cc(j,k)+cc(j-1,k))-(Sr/2*h^2)*(bb(j+1,k)-2*bb(j,k)+bb(j-1,k));
end
r1(n,k)= 0;
r2(n,k)=0;
r3(n,k)=0;
for j=1:n
rr{j,k}=[r1(j,k);r2(j,k);r3(j,k)];
end
gamma{1,k}=inv(a{1,k})*c{1,k};
for j=2:n-1
a{j,k}=a{j,k}-(b{j,k}*gamma{j-1,k});
gamma{j,k}=inv(a{j,k})*c{j,k};
end
y{1}=inv(a{1})*rr{1};
for j=2:n
y{j}=inv(a{j})*(rr{j}-b{j}*y{j-1});
end
x{n}=y{n};
for j=n-1:-1:1
x{j}=y{j}-(gamma{j})*x{j+1};
end
for j=n:-1:1
u(j,k)=x{j}(1,1);
z(j,k)=x{j}(2,1);
q(j,k)=x{j}(3,1);
end
for j=1:n
xx(j,k)= aa(j,k)+u(j,k);
yy(j,k)= bb(j,k)+z(j,k);
zz(j,k)= cc(j,k)+q(j,k);
end
for j=1:n-1
%U(j)=-((1+(1/B))*((xx(j+1)-xx(j))/h))
%U(j)=-((yy(j+1)-yy(j))/2*h)
end
%ee=meshgrid(xx);
%V=trapz(ee);
%eee=meshgrid(V);
%[XX,YY]=meshgrid(t,s);
%XXX=meshgrid(xx);
%surf(XX,YY,XXX)
%contour(eee)
figure(1)
plot(t,xx,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’-‘,’color’,’k’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘u’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold on
figure(2)
plot(t,yy,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’-‘,’color’,’k’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘Theta(eta)’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold on
figure(3)
plot(t,zz,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’–‘,’color’,’r’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘Phi(eta)’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold oni have attached my matlb code for solving system of PDE ∂u/∂t=(∂^2 u)/〖∂η〗^2 +α (∂^3 u)/〖∂η〗^3 +δcφ+Grθ-Mu
∂θ/∂t=1/Pr (∂^2 θ)/〖∂η〗^2 +D_f (∂^2 φ)/〖∂η〗^2
∂φ/∂t=1/S_c (∂^2 φ)/〖∂η〗^2 +S_r (∂^2 θ)/〖∂η〗^2
when η→0
when η→0:u=sin(wt),θ=1 ,φ=1
when η→∞:u→0,θ→0,φ→0
But,i’m confused how to set boundary conditions in this code. Also i want to set these skin friction and nusselt number expressions: C_f=-(∂u/∂η) at η=0
Nu〖Re〗_x^(-1)=-(∂θ/∂η) at η=0
in this code;
function yy= crank
n=105;
h=0.01;
m=0.1;
B=0; %B=0.0001;
Gr=2; %Gr=0.1=Delt. Gs=Dels
A=2; %A=alpha
Pr=5;
Gs=1; %3.5
Sc=1.5;
M=9; %M=30,12
Df=5;
Sr=10;
Ec=0.1; % 0.01-0.1(0-1)
t(1)=0;
s(1)=0;
for j=2:n
t(j)=t(j-1)+h;
end
for j=2:n
s(j)=s(j-1)+m;
end
k=1;
for j=1:n
aa(j,k)=exp(-0.15*Pr^2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k)-2*bb(j,k)+bb(j-1,k))-(Df/2*h^2)*(cc(j+1,k)-2*cc(j,k)+cc(j-1,k));
r3(j,k)=-(exp((-t(j)))/h)-(1/2*Sc*h^2)*(exp(-t(j+1))-2*exp(-t(j))+exp(-t(j-1)))-(Sr/2*h^2)*(exp(-t(j+1))-2*exp(-t(j))+exp(-t(j-1)))+ (cc(j,k)/h)…
-(1/2*Sc*h^2)*(cc(j+1,k)-2*cc(j,k)+cc(j-1,k))-(Sr/2*h^2)*(bb(j+1,k)-2*bb(j,k)+bb(j-1,k));
end
r1(n,k)= 0;
r2(n,k)=0;
r3(n,k)=0;
for j=1:n
rr{j,k}=[r1(j,k);r2(j,k);r3(j,k)];
end
gamma{1,k}=inv(a{1,k})*c{1,k};
for j=2:n-1
a{j,k}=a{j,k}-(b{j,k}*gamma{j-1,k});
gamma{j,k}=inv(a{j,k})*c{j,k};
end
y{1}=inv(a{1})*rr{1};
for j=2:n
y{j}=inv(a{j})*(rr{j}-b{j}*y{j-1});
end
x{n}=y{n};
for j=n-1:-1:1
x{j}=y{j}-(gamma{j})*x{j+1};
end
for j=n:-1:1
u(j,k)=x{j}(1,1);
z(j,k)=x{j}(2,1);
q(j,k)=x{j}(3,1);
end
for j=1:n
xx(j,k)= aa(j,k)+u(j,k);
yy(j,k)= bb(j,k)+z(j,k);
zz(j,k)= cc(j,k)+q(j,k);
end
for j=1:n-1
%U(j)=-((1+(1/B))*((xx(j+1)-xx(j))/h))
%U(j)=-((yy(j+1)-yy(j))/2*h)
end
%ee=meshgrid(xx);
%V=trapz(ee);
%eee=meshgrid(V);
%[XX,YY]=meshgrid(t,s);
%XXX=meshgrid(xx);
%surf(XX,YY,XXX)
%contour(eee)
figure(1)
plot(t,xx,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’-‘,’color’,’k’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘u’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold on
figure(2)
plot(t,yy,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’-‘,’color’,’k’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘Theta(eta)’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold on
figure(3)
plot(t,zz,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’–‘,’color’,’r’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘Phi(eta)’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold on i have attached my matlb code for solving system of PDE ∂u/∂t=(∂^2 u)/〖∂η〗^2 +α (∂^3 u)/〖∂η〗^3 +δcφ+Grθ-Mu
∂θ/∂t=1/Pr (∂^2 θ)/〖∂η〗^2 +D_f (∂^2 φ)/〖∂η〗^2
∂φ/∂t=1/S_c (∂^2 φ)/〖∂η〗^2 +S_r (∂^2 θ)/〖∂η〗^2
when η→0
when η→0:u=sin(wt),θ=1 ,φ=1
when η→∞:u→0,θ→0,φ→0
But,i’m confused how to set boundary conditions in this code. Also i want to set these skin friction and nusselt number expressions: C_f=-(∂u/∂η) at η=0
Nu〖Re〗_x^(-1)=-(∂θ/∂η) at η=0
in this code;
function yy= crank
n=105;
h=0.01;
m=0.1;
B=0; %B=0.0001;
Gr=2; %Gr=0.1=Delt. Gs=Dels
A=2; %A=alpha
Pr=5;
Gs=1; %3.5
Sc=1.5;
M=9; %M=30,12
Df=5;
Sr=10;
Ec=0.1; % 0.01-0.1(0-1)
t(1)=0;
s(1)=0;
for j=2:n
t(j)=t(j-1)+h;
end
for j=2:n
s(j)=s(j-1)+m;
end
k=1;
for j=1:n
aa(j,k)=exp(-0.15*Pr^2*t(j)*Ec^-0.1/Gr^0.1); % Guess M*Gr*Gs*S
bb(j,k)=exp(-t(j)*Sc/(Ec)^0.01*M); %bb(j,k)=exp(-Pr^2*t(j)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c*h^2)*(exp(-t(j+1))-2*exp(-t(j))+exp(-t(j-1)))-(Sr/2*h^2)*(exp(-t(j+1))-2*exp(-t(j))+exp(-t(j-1)))+ (cc(j,k)/h)…
-(1/2*Sc*h^2)*(cc(j+1,k)-2*cc(j,k)+cc(j-1,k))-(Sr/2*h^2)*(bb(j+1,k)-2*bb(j,k)+bb(j-1,k));
end
r1(n,k)= 0;
r2(n,k)=0;
r3(n,k)=0;
for j=1:n
rr{j,k}=[r1(j,k);r2(j,k);r3(j,k)];
end
gamma{1,k}=inv(a{1,k})*c{1,k};
for j=2:n-1
a{j,k}=a{j,k}-(b{j,k}*gamma{j-1,k});
gamma{j,k}=inv(a{j,k})*c{j,k};
end
y{1}=inv(a{1})*rr{1};
for j=2:n
y{j}=inv(a{j})*(rr{j}-b{j}*y{j-1});
end
x{n}=y{n};
for j=n-1:-1:1
x{j}=y{j}-(gamma{j})*x{j+1};
end
for j=n:-1:1
u(j,k)=x{j}(1,1);
z(j,k)=x{j}(2,1);
q(j,k)=x{j}(3,1);
end
for j=1:n
xx(j,k)= aa(j,k)+u(j,k);
yy(j,k)= bb(j,k)+z(j,k);
zz(j,k)= cc(j,k)+q(j,k);
end
for j=1:n-1
%U(j)=-((1+(1/B))*((xx(j+1)-xx(j))/h))
%U(j)=-((yy(j+1)-yy(j))/2*h)
end
%ee=meshgrid(xx);
%V=trapz(ee);
%eee=meshgrid(V);
%[XX,YY]=meshgrid(t,s);
%XXX=meshgrid(xx);
%surf(XX,YY,XXX)
%contour(eee)
figure(1)
plot(t,xx,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’-‘,’color’,’k’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘u’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold on
figure(2)
plot(t,yy,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’-‘,’color’,’k’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘Theta(eta)’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold on
figure(3)
plot(t,zz,’LineWidth’,2,’MarkerSize’,16,’linestyle’,’–‘,’color’,’r’)
xlabel(‘eta’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
ylabel(‘Phi(eta)’,’Interpreter’,’tex’,’FontSize’,16,’FontWeight’,’bold’);
grid on
hold on system of pde’s, crank nicloson method in matlab, skin friction and nusselt number MATLAB Answers — New Questions
Modbus RTU Write Simulink Block error
Hi community,
I am starting with the setup of a modbus RTU communication between my matlab simulink model and some surrounding devices. Using the new simulink block "modbus client read", I can read the register of my external device, which shows me, that I’ve created a stable communication. However, if I want to write a register on the device, using the block "modbus client write", I get the following error:
Error:An error occurred during simulation and the simulation was terminated
Caused by:
MATLAB System block ‘untitled/Modbus Client Write/internalModbus’ error occurred when invoking ‘stepImpl’ method of ‘icomm.system.ModbusWrite’. The error was thrown from ‘
‘C:Program FilesMATLABR2024btoolboxicommmodbusmodbusmodbusblks+icomm+systemModbusWrite.p’ at line 0′.
The Modbus server returned an invalid address error. Address + number of values to write is out of range.
The config of the write-block is pictured:
As aforementioned, it’s the same connection as used for the reading process. The model is quite simple and broken down to the minimum, but I get the error anyway:
Now I am struggling how to proceed with this error. Maybe someone can help me out!
Best
MarcoHi community,
I am starting with the setup of a modbus RTU communication between my matlab simulink model and some surrounding devices. Using the new simulink block "modbus client read", I can read the register of my external device, which shows me, that I’ve created a stable communication. However, if I want to write a register on the device, using the block "modbus client write", I get the following error:
Error:An error occurred during simulation and the simulation was terminated
Caused by:
MATLAB System block ‘untitled/Modbus Client Write/internalModbus’ error occurred when invoking ‘stepImpl’ method of ‘icomm.system.ModbusWrite’. The error was thrown from ‘
‘C:Program FilesMATLABR2024btoolboxicommmodbusmodbusmodbusblks+icomm+systemModbusWrite.p’ at line 0′.
The Modbus server returned an invalid address error. Address + number of values to write is out of range.
The config of the write-block is pictured:
As aforementioned, it’s the same connection as used for the reading process. The model is quite simple and broken down to the minimum, but I get the error anyway:
Now I am struggling how to proceed with this error. Maybe someone can help me out!
Best
Marco Hi community,
I am starting with the setup of a modbus RTU communication between my matlab simulink model and some surrounding devices. Using the new simulink block "modbus client read", I can read the register of my external device, which shows me, that I’ve created a stable communication. However, if I want to write a register on the device, using the block "modbus client write", I get the following error:
Error:An error occurred during simulation and the simulation was terminated
Caused by:
MATLAB System block ‘untitled/Modbus Client Write/internalModbus’ error occurred when invoking ‘stepImpl’ method of ‘icomm.system.ModbusWrite’. The error was thrown from ‘
‘C:Program FilesMATLABR2024btoolboxicommmodbusmodbusmodbusblks+icomm+systemModbusWrite.p’ at line 0′.
The Modbus server returned an invalid address error. Address + number of values to write is out of range.
The config of the write-block is pictured:
As aforementioned, it’s the same connection as used for the reading process. The model is quite simple and broken down to the minimum, but I get the error anyway:
Now I am struggling how to proceed with this error. Maybe someone can help me out!
Best
Marco simulink, modbus, modbusrtu, writeregister MATLAB Answers — New Questions
How to use the Visual Studio Code for Simulink c-caller Debugging with MATLAB Coder Interface?
I have installed the MATLAB Coder Interface for VSCode, (matlab-coder-interface-vscode-debugging.vsix) and I have the C-caller simulink function and I’d like to know how can I use this extension for C-caller c-function to debug it.
and this link "Simulate custom code in a separate process" is not clear to me how to use external tool (VSCode) and seprate process …
Please can you suggest the steps to use VS Code to debug the c-code for C-caller simulink funtion?
Thank you very much.I have installed the MATLAB Coder Interface for VSCode, (matlab-coder-interface-vscode-debugging.vsix) and I have the C-caller simulink function and I’d like to know how can I use this extension for C-caller c-function to debug it.
and this link "Simulate custom code in a separate process" is not clear to me how to use external tool (VSCode) and seprate process …
Please can you suggest the steps to use VS Code to debug the c-code for C-caller simulink funtion?
Thank you very much. I have installed the MATLAB Coder Interface for VSCode, (matlab-coder-interface-vscode-debugging.vsix) and I have the C-caller simulink function and I’d like to know how can I use this extension for C-caller c-function to debug it.
and this link "Simulate custom code in a separate process" is not clear to me how to use external tool (VSCode) and seprate process …
Please can you suggest the steps to use VS Code to debug the c-code for C-caller simulink funtion?
Thank you very much. vscode to debug simulink MATLAB Answers — New Questions
How to view a 3D Figure from “below”, e.g. z-axis facing downwards
I’m looking for a possibility to view/rotate a North-East-Down Coordinate Frame in a 3D Figure.
By casually plotting a cartesian coordinate system z is facing upwards, and by rotating it with the hand tool, it is not possible to "flip" the figure so that z is facing down.
If you set the z-Axis to ‘reverse’ the right hand system becomes a left-hand system, thus this is not a solution.
figure
plot3(0,0,0)
line([0 0.1],[0 0],[0 0],’LineWidth’,5,’DisplayName’,’X’)
line([0 0],[0 0.1],[0 0],’LineWidth’,5,’DisplayName’,’Y’)
line([0 0],[0 0],[0 0.1],’LineWidth’,5,’DisplayName’,’Z’)
legend
Take the above picture, I would like a solution where the Z-Line is Facing downwards, without changing the coordinate-systemI’m looking for a possibility to view/rotate a North-East-Down Coordinate Frame in a 3D Figure.
By casually plotting a cartesian coordinate system z is facing upwards, and by rotating it with the hand tool, it is not possible to "flip" the figure so that z is facing down.
If you set the z-Axis to ‘reverse’ the right hand system becomes a left-hand system, thus this is not a solution.
figure
plot3(0,0,0)
line([0 0.1],[0 0],[0 0],’LineWidth’,5,’DisplayName’,’X’)
line([0 0],[0 0.1],[0 0],’LineWidth’,5,’DisplayName’,’Y’)
line([0 0],[0 0],[0 0.1],’LineWidth’,5,’DisplayName’,’Z’)
legend
Take the above picture, I would like a solution where the Z-Line is Facing downwards, without changing the coordinate-system I’m looking for a possibility to view/rotate a North-East-Down Coordinate Frame in a 3D Figure.
By casually plotting a cartesian coordinate system z is facing upwards, and by rotating it with the hand tool, it is not possible to "flip" the figure so that z is facing down.
If you set the z-Axis to ‘reverse’ the right hand system becomes a left-hand system, thus this is not a solution.
figure
plot3(0,0,0)
line([0 0.1],[0 0],[0 0],’LineWidth’,5,’DisplayName’,’X’)
line([0 0],[0 0.1],[0 0],’LineWidth’,5,’DisplayName’,’Y’)
line([0 0],[0 0],[0 0.1],’LineWidth’,5,’DisplayName’,’Z’)
legend
Take the above picture, I would like a solution where the Z-Line is Facing downwards, without changing the coordinate-system ned, coordinatesystem, rotation MATLAB Answers — New Questions
Troubleshooting Signal Logging in SDI for FPGA Outputs in Speedgoat Motion Control HDL I/O Blockset
In pwm_example_hdlc.slx example from Speedgoat Motion Control HDL I/O Blockset v1.0 (R2024b). I want to view logged signals in SDI. There are PWM and CAP signals in the example which are set to logging.
I succesfully generated bitstream and run example on Speedgoat P3 Perfomance. The hardware generates PWM signals as expected (confirmed with oscilloscope). However, the SDI does not have any signal available during or post model execution.
During model build the following warning(s) is issued:
Warning: Unable to instrument ‘gm_pwm_example_hdlc_slrt/DUT PWM and CAP/DataTypeConversion:1’: Unable to stream signal
‘gm_pwm_example_hdlc_slrt/DUT PWM and CAP/DataTypeConversion:1’. Possible reasons include:
(1) Signal is not available in application.
(2) Signal does not use globally accessible memory in application.
(3) Signal connects to a MessageSend block.
(4) Signal has inherited sample time.
(5) Signal is discontiguous.
For more suggestions to resolve this issue, see Troubleshoot Signals for Streaming or File Log logging.
I followed the advice given in Troubleshoot Signals for Streaming or File Log logging and in this post:
added test point
added Signal Copy Block
made PWM_A signal globally accessible
But the issue persist and no data appears in SDI (external mode, command line, slrtExplorer).
If I add the rate transition block, the signal appear in SDI, however the value is 0 (Output port sample time is 1e-4s), whereas PWM perion is 1e-3s.
If I add sine generator block in the model and log its output, this sine output signal appears in SDI as expected.
What can be the reason that the outputs from FPGA cannot be visualized in the model?In pwm_example_hdlc.slx example from Speedgoat Motion Control HDL I/O Blockset v1.0 (R2024b). I want to view logged signals in SDI. There are PWM and CAP signals in the example which are set to logging.
I succesfully generated bitstream and run example on Speedgoat P3 Perfomance. The hardware generates PWM signals as expected (confirmed with oscilloscope). However, the SDI does not have any signal available during or post model execution.
During model build the following warning(s) is issued:
Warning: Unable to instrument ‘gm_pwm_example_hdlc_slrt/DUT PWM and CAP/DataTypeConversion:1’: Unable to stream signal
‘gm_pwm_example_hdlc_slrt/DUT PWM and CAP/DataTypeConversion:1’. Possible reasons include:
(1) Signal is not available in application.
(2) Signal does not use globally accessible memory in application.
(3) Signal connects to a MessageSend block.
(4) Signal has inherited sample time.
(5) Signal is discontiguous.
For more suggestions to resolve this issue, see Troubleshoot Signals for Streaming or File Log logging.
I followed the advice given in Troubleshoot Signals for Streaming or File Log logging and in this post:
added test point
added Signal Copy Block
made PWM_A signal globally accessible
But the issue persist and no data appears in SDI (external mode, command line, slrtExplorer).
If I add the rate transition block, the signal appear in SDI, however the value is 0 (Output port sample time is 1e-4s), whereas PWM perion is 1e-3s.
If I add sine generator block in the model and log its output, this sine output signal appears in SDI as expected.
What can be the reason that the outputs from FPGA cannot be visualized in the model? In pwm_example_hdlc.slx example from Speedgoat Motion Control HDL I/O Blockset v1.0 (R2024b). I want to view logged signals in SDI. There are PWM and CAP signals in the example which are set to logging.
I succesfully generated bitstream and run example on Speedgoat P3 Perfomance. The hardware generates PWM signals as expected (confirmed with oscilloscope). However, the SDI does not have any signal available during or post model execution.
During model build the following warning(s) is issued:
Warning: Unable to instrument ‘gm_pwm_example_hdlc_slrt/DUT PWM and CAP/DataTypeConversion:1’: Unable to stream signal
‘gm_pwm_example_hdlc_slrt/DUT PWM and CAP/DataTypeConversion:1’. Possible reasons include:
(1) Signal is not available in application.
(2) Signal does not use globally accessible memory in application.
(3) Signal connects to a MessageSend block.
(4) Signal has inherited sample time.
(5) Signal is discontiguous.
For more suggestions to resolve this issue, see Troubleshoot Signals for Streaming or File Log logging.
I followed the advice given in Troubleshoot Signals for Streaming or File Log logging and in this post:
added test point
added Signal Copy Block
made PWM_A signal globally accessible
But the issue persist and no data appears in SDI (external mode, command line, slrtExplorer).
If I add the rate transition block, the signal appear in SDI, however the value is 0 (Output port sample time is 1e-4s), whereas PWM perion is 1e-3s.
If I add sine generator block in the model and log its output, this sine output signal appears in SDI as expected.
What can be the reason that the outputs from FPGA cannot be visualized in the model? real-time, speedgoat, sdi MATLAB Answers — New Questions
Simulating Induction motor inter-turn short circuit faults
Hi! Using Simulink / Simscape I wish to Simulate an Induction Motor for getting normal operation and inter-turn short circuit fault data for training my Machine learning based fault classifier. I basically desire a model that incorporates saturation and iron losses effects as well. Any help and guidance is requested.Hi! Using Simulink / Simscape I wish to Simulate an Induction Motor for getting normal operation and inter-turn short circuit fault data for training my Machine learning based fault classifier. I basically desire a model that incorporates saturation and iron losses effects as well. Any help and guidance is requested. Hi! Using Simulink / Simscape I wish to Simulate an Induction Motor for getting normal operation and inter-turn short circuit fault data for training my Machine learning based fault classifier. I basically desire a model that incorporates saturation and iron losses effects as well. Any help and guidance is requested. induction-motor model, simulink, simscape MATLAB Answers — New Questions
Assigning plot to an existing axes Matlab GUI
Hi,
I have a GUI in Matlab and several functions in it. One function is for plotting a figure, I need to assign it to an existing axes in GUI. I have tried several options, nothing has worked out yet.
Code below is the current option I had tried before I asked here.
set(‘CurrentAxes’,’axes11′)
plot(VyQRS(:,2));
grid on
The plot of VyQRS I need to assign to axes11.
Could you please give me any hint?Hi,
I have a GUI in Matlab and several functions in it. One function is for plotting a figure, I need to assign it to an existing axes in GUI. I have tried several options, nothing has worked out yet.
Code below is the current option I had tried before I asked here.
set(‘CurrentAxes’,’axes11′)
plot(VyQRS(:,2));
grid on
The plot of VyQRS I need to assign to axes11.
Could you please give me any hint? Hi,
I have a GUI in Matlab and several functions in it. One function is for plotting a figure, I need to assign it to an existing axes in GUI. I have tried several options, nothing has worked out yet.
Code below is the current option I had tried before I asked here.
set(‘CurrentAxes’,’axes11′)
plot(VyQRS(:,2));
grid on
The plot of VyQRS I need to assign to axes11.
Could you please give me any hint? matlab gui, plotting, guide MATLAB Answers — New Questions
Construction of subplots for the comparison of two models
Hi Everyone!
I would like to know what kind of subplot (code) I could use to make similar graphics.
Best regard,Hi Everyone!
I would like to know what kind of subplot (code) I could use to make similar graphics.
Best regard, Hi Everyone!
I would like to know what kind of subplot (code) I could use to make similar graphics.
Best regard, two mdels comparison, comparison models MATLAB Answers — New Questions