Category: Matlab
Category Archives: Matlab
Why does Matlab crash when I try to access .NET 6.0 (core)?
Note: Workaround is to remove .NET 9.0 from PC to resolve conflicts with 6.0.
This might be a .NET issue as a whole, but I only see it using Matlab, so I am posting here to help others out facing the same issues.
I have a .dll from one of the groups I work with for communicating to our devices. The .dll was built in .NET 6.0 (core) (x64). I have been able to use it in the past in Matlab, but have now run into issues since installing Visual Studio 2022. It was discovered that Matlab would reference the most recent installation of .NET (9.0 in my case) which was installed by VS 2022. When I set "core" as the environment in Matlab (dotnetenv("core")), I would then make the .NET assembly visible to Matlab using NET.addAssembly("insert path here"). When Matlab got to this step, it would buffer for about 10 seconds then crash immediately with no crash report. Getting help from my local IT, we pin pointed it to the .NET 9.0 install causing the problem.
To get around this, you can either uninstall 9.0 or set up an environment variable in your system properties called "DOTNET_ROOT" that can force a path to be referenced.
So I would like to ask if anyone else has faced this issue in Matlab? Is it an unexpected error that needs an error handle? I am naive to .net, and really only know the particular dll I interact with to do my methods, etc.Note: Workaround is to remove .NET 9.0 from PC to resolve conflicts with 6.0.
This might be a .NET issue as a whole, but I only see it using Matlab, so I am posting here to help others out facing the same issues.
I have a .dll from one of the groups I work with for communicating to our devices. The .dll was built in .NET 6.0 (core) (x64). I have been able to use it in the past in Matlab, but have now run into issues since installing Visual Studio 2022. It was discovered that Matlab would reference the most recent installation of .NET (9.0 in my case) which was installed by VS 2022. When I set "core" as the environment in Matlab (dotnetenv("core")), I would then make the .NET assembly visible to Matlab using NET.addAssembly("insert path here"). When Matlab got to this step, it would buffer for about 10 seconds then crash immediately with no crash report. Getting help from my local IT, we pin pointed it to the .NET 9.0 install causing the problem.
To get around this, you can either uninstall 9.0 or set up an environment variable in your system properties called "DOTNET_ROOT" that can force a path to be referenced.
So I would like to ask if anyone else has faced this issue in Matlab? Is it an unexpected error that needs an error handle? I am naive to .net, and really only know the particular dll I interact with to do my methods, etc. Note: Workaround is to remove .NET 9.0 from PC to resolve conflicts with 6.0.
This might be a .NET issue as a whole, but I only see it using Matlab, so I am posting here to help others out facing the same issues.
I have a .dll from one of the groups I work with for communicating to our devices. The .dll was built in .NET 6.0 (core) (x64). I have been able to use it in the past in Matlab, but have now run into issues since installing Visual Studio 2022. It was discovered that Matlab would reference the most recent installation of .NET (9.0 in my case) which was installed by VS 2022. When I set "core" as the environment in Matlab (dotnetenv("core")), I would then make the .NET assembly visible to Matlab using NET.addAssembly("insert path here"). When Matlab got to this step, it would buffer for about 10 seconds then crash immediately with no crash report. Getting help from my local IT, we pin pointed it to the .NET 9.0 install causing the problem.
To get around this, you can either uninstall 9.0 or set up an environment variable in your system properties called "DOTNET_ROOT" that can force a path to be referenced.
So I would like to ask if anyone else has faced this issue in Matlab? Is it an unexpected error that needs an error handle? I am naive to .net, and really only know the particular dll I interact with to do my methods, etc. .net MATLAB Answers — New Questions
Large Gregorian Antenna simulations at high frequency
If I have a large Gregorian antenna (2-3 meter) and need to operate it in frequency range 20/30 GHz, I get a problem of out of memory and need RAM in range of 200G or more !! Is there a solution to this issue? By decreasing number of iterations or decrease accuracy needed ?If I have a large Gregorian antenna (2-3 meter) and need to operate it in frequency range 20/30 GHz, I get a problem of out of memory and need RAM in range of 200G or more !! Is there a solution to this issue? By decreasing number of iterations or decrease accuracy needed ? If I have a large Gregorian antenna (2-3 meter) and need to operate it in frequency range 20/30 GHz, I get a problem of out of memory and need RAM in range of 200G or more !! Is there a solution to this issue? By decreasing number of iterations or decrease accuracy needed ? antenna, high frequency MATLAB Answers — New Questions
VPP Virtual Power Plants model SIMULINK
Hello everyone! Can I have some files about VPP Virtual Power Plants research for reference during my studies? Please help me.Hello everyone! Can I have some files about VPP Virtual Power Plants research for reference during my studies? Please help me. Hello everyone! Can I have some files about VPP Virtual Power Plants research for reference during my studies? Please help me. vpp, model MATLAB Answers — New Questions
lsqlin and its constraints
Hi,
How does MATLAB impose the Upper and Lower Bound on the
unknowns in the lsqlin routine?
Does it build a quadratic format of the constraints and ads it to the solution?!Hi,
How does MATLAB impose the Upper and Lower Bound on the
unknowns in the lsqlin routine?
Does it build a quadratic format of the constraints and ads it to the solution?! Hi,
How does MATLAB impose the Upper and Lower Bound on the
unknowns in the lsqlin routine?
Does it build a quadratic format of the constraints and ads it to the solution?! optimization, curve fitting MATLAB Answers — New Questions
How to defined Binary variables with equality and inequality Constraints while using Genetic Algorithm?
I defined equality and inequality constraints and for binary variables I used IntCon, But then ga gives error that equality constraints cannot used with integer. But I need equality and inequality constraints with binary variables to get satisfy result.
If anyone know, how to used both constraints with binary variables and integer please tell me.I defined equality and inequality constraints and for binary variables I used IntCon, But then ga gives error that equality constraints cannot used with integer. But I need equality and inequality constraints with binary variables to get satisfy result.
If anyone know, how to used both constraints with binary variables and integer please tell me. I defined equality and inequality constraints and for binary variables I used IntCon, But then ga gives error that equality constraints cannot used with integer. But I need equality and inequality constraints with binary variables to get satisfy result.
If anyone know, how to used both constraints with binary variables and integer please tell me. binary variables with equality constraints, integer variables with equality constraints MATLAB Answers — New Questions
Code generation paths of model references
Hi,
I have a top model in which there are several model references.
If I generate code, code of top model is generated in folder:
code_generationtop_model_ert_rtw
code of model references is generated into:
code_generationslprjertmodel_reference1
code_generationslprjertmodel_reference2
code_generationslprjertmodel_reference3
…
and there is also:
code_generationslprjertshared_utils
If I have for example 100 different model references in my top model, and if I would like to link external IDE enviroment directly to code generation directory in simulink project, I would have to set 100 paths in IDE enviroment (metrowerks eclipse 10.5).
Is it possible to compact the code of model references in single file, or is it possible to generate all .c, .h files into one directory.
Or any other suggestion would be welcomed.
Thank you and best regards,
DejanHi,
I have a top model in which there are several model references.
If I generate code, code of top model is generated in folder:
code_generationtop_model_ert_rtw
code of model references is generated into:
code_generationslprjertmodel_reference1
code_generationslprjertmodel_reference2
code_generationslprjertmodel_reference3
…
and there is also:
code_generationslprjertshared_utils
If I have for example 100 different model references in my top model, and if I would like to link external IDE enviroment directly to code generation directory in simulink project, I would have to set 100 paths in IDE enviroment (metrowerks eclipse 10.5).
Is it possible to compact the code of model references in single file, or is it possible to generate all .c, .h files into one directory.
Or any other suggestion would be welcomed.
Thank you and best regards,
Dejan Hi,
I have a top model in which there are several model references.
If I generate code, code of top model is generated in folder:
code_generationtop_model_ert_rtw
code of model references is generated into:
code_generationslprjertmodel_reference1
code_generationslprjertmodel_reference2
code_generationslprjertmodel_reference3
…
and there is also:
code_generationslprjertshared_utils
If I have for example 100 different model references in my top model, and if I would like to link external IDE enviroment directly to code generation directory in simulink project, I would have to set 100 paths in IDE enviroment (metrowerks eclipse 10.5).
Is it possible to compact the code of model references in single file, or is it possible to generate all .c, .h files into one directory.
Or any other suggestion would be welcomed.
Thank you and best regards,
Dejan code generation path MATLAB Answers — New Questions
delay and sum beamforming
I am making a program to acheive delay and sum beamforming,
I looked for examples of this online and found one relatable. The code is given below. When i run the program i get this error
%% Examples on delay-and-sum response for different arrays and input signals
%% 1D-array case
% Create vectors of x- and y-coordinates of microphone positions
xPos = -0.8:0.2:0.8; % 1xP vector of x-positions [m]
yPos = zeros(1, numel(xPos)); % 1xP vector of y-positions [m]
zPos = zeros(1, numel(xPos));
elementWeights = ones(1, numel(xPos))/numel(xPos); % 1xP vector of weightings
% Define arriving angles and frequency of input signals
thetaArrivalAngles = [-30 10]; % degrees
phiArrivalAngles = [0 0]; % degrees
f = 800; % [Hz]
c = 340; % [m/s]
fs = 44.1e3; % [Hz]
% Define array scanning angles (1D, so phi = 0)
thetaScanAngles = -90:0.1:90; % degrees
phiScanAngles = 0; % degrees
% Create input signal
inputSignal = createSignal(xPos, yPos, zPos, f, c, fs, thetaArrivalAngles, phiArrivalAngles);
% Create steering vector/matrix
e = steeringVector(xPos, yPos, zPos, f, c, thetaScanAngles, phiScanAngles);
% Create cross spectral matrix
R = crossSpectralMatrix(inputSignal);
% Calculate delay-and-sum steered response
S = steeredResponseDelayAndSum(R, e, elementWeights);
%Normalise spectrum
spectrumNormalized = abs(S)/max(abs(S));
%Convert to decibel
spectrumLog = 10*log10(spectrumNormalized);
%Plot array
fig1 = figure;
fig1.Color = ‘w’;
ax = axes(‘Parent’, fig1);
scatter(ax, xPos, yPos, 20, ‘filled’)
axis(ax, ‘square’)
ax.XLim = [-1 1];
ax.YLim = [-1 1];
grid(ax, ‘on’)
title(ax, ‘Microphone positions’)
%Plot steered response with indicator lines
fig2 = figure;
fig2.Color = ‘w’;
ax = axes(‘Parent’, fig2);
plot(ax, thetaScanAngles, spectrumLog)
grid(ax, ‘on’)
ax.XLim = [thetaScanAngles(1) thetaScanAngles(end)];
for j=1:numel(thetaArrivalAngles)
indx = find(thetaScanAngles >= thetaArrivalAngles(j), 1);
line(ax, [thetaScanAngles(indx) thetaScanAngles(indx)], ax.YLim,’LineWidth’, 1, ‘Color’, ‘r’, ‘LineStyle’, ‘–‘);
end
xlabel(ax, ‘theta’)
ylabel(ax, ‘dB’)I am making a program to acheive delay and sum beamforming,
I looked for examples of this online and found one relatable. The code is given below. When i run the program i get this error
%% Examples on delay-and-sum response for different arrays and input signals
%% 1D-array case
% Create vectors of x- and y-coordinates of microphone positions
xPos = -0.8:0.2:0.8; % 1xP vector of x-positions [m]
yPos = zeros(1, numel(xPos)); % 1xP vector of y-positions [m]
zPos = zeros(1, numel(xPos));
elementWeights = ones(1, numel(xPos))/numel(xPos); % 1xP vector of weightings
% Define arriving angles and frequency of input signals
thetaArrivalAngles = [-30 10]; % degrees
phiArrivalAngles = [0 0]; % degrees
f = 800; % [Hz]
c = 340; % [m/s]
fs = 44.1e3; % [Hz]
% Define array scanning angles (1D, so phi = 0)
thetaScanAngles = -90:0.1:90; % degrees
phiScanAngles = 0; % degrees
% Create input signal
inputSignal = createSignal(xPos, yPos, zPos, f, c, fs, thetaArrivalAngles, phiArrivalAngles);
% Create steering vector/matrix
e = steeringVector(xPos, yPos, zPos, f, c, thetaScanAngles, phiScanAngles);
% Create cross spectral matrix
R = crossSpectralMatrix(inputSignal);
% Calculate delay-and-sum steered response
S = steeredResponseDelayAndSum(R, e, elementWeights);
%Normalise spectrum
spectrumNormalized = abs(S)/max(abs(S));
%Convert to decibel
spectrumLog = 10*log10(spectrumNormalized);
%Plot array
fig1 = figure;
fig1.Color = ‘w’;
ax = axes(‘Parent’, fig1);
scatter(ax, xPos, yPos, 20, ‘filled’)
axis(ax, ‘square’)
ax.XLim = [-1 1];
ax.YLim = [-1 1];
grid(ax, ‘on’)
title(ax, ‘Microphone positions’)
%Plot steered response with indicator lines
fig2 = figure;
fig2.Color = ‘w’;
ax = axes(‘Parent’, fig2);
plot(ax, thetaScanAngles, spectrumLog)
grid(ax, ‘on’)
ax.XLim = [thetaScanAngles(1) thetaScanAngles(end)];
for j=1:numel(thetaArrivalAngles)
indx = find(thetaScanAngles >= thetaArrivalAngles(j), 1);
line(ax, [thetaScanAngles(indx) thetaScanAngles(indx)], ax.YLim,’LineWidth’, 1, ‘Color’, ‘r’, ‘LineStyle’, ‘–‘);
end
xlabel(ax, ‘theta’)
ylabel(ax, ‘dB’) I am making a program to acheive delay and sum beamforming,
I looked for examples of this online and found one relatable. The code is given below. When i run the program i get this error
%% Examples on delay-and-sum response for different arrays and input signals
%% 1D-array case
% Create vectors of x- and y-coordinates of microphone positions
xPos = -0.8:0.2:0.8; % 1xP vector of x-positions [m]
yPos = zeros(1, numel(xPos)); % 1xP vector of y-positions [m]
zPos = zeros(1, numel(xPos));
elementWeights = ones(1, numel(xPos))/numel(xPos); % 1xP vector of weightings
% Define arriving angles and frequency of input signals
thetaArrivalAngles = [-30 10]; % degrees
phiArrivalAngles = [0 0]; % degrees
f = 800; % [Hz]
c = 340; % [m/s]
fs = 44.1e3; % [Hz]
% Define array scanning angles (1D, so phi = 0)
thetaScanAngles = -90:0.1:90; % degrees
phiScanAngles = 0; % degrees
% Create input signal
inputSignal = createSignal(xPos, yPos, zPos, f, c, fs, thetaArrivalAngles, phiArrivalAngles);
% Create steering vector/matrix
e = steeringVector(xPos, yPos, zPos, f, c, thetaScanAngles, phiScanAngles);
% Create cross spectral matrix
R = crossSpectralMatrix(inputSignal);
% Calculate delay-and-sum steered response
S = steeredResponseDelayAndSum(R, e, elementWeights);
%Normalise spectrum
spectrumNormalized = abs(S)/max(abs(S));
%Convert to decibel
spectrumLog = 10*log10(spectrumNormalized);
%Plot array
fig1 = figure;
fig1.Color = ‘w’;
ax = axes(‘Parent’, fig1);
scatter(ax, xPos, yPos, 20, ‘filled’)
axis(ax, ‘square’)
ax.XLim = [-1 1];
ax.YLim = [-1 1];
grid(ax, ‘on’)
title(ax, ‘Microphone positions’)
%Plot steered response with indicator lines
fig2 = figure;
fig2.Color = ‘w’;
ax = axes(‘Parent’, fig2);
plot(ax, thetaScanAngles, spectrumLog)
grid(ax, ‘on’)
ax.XLim = [thetaScanAngles(1) thetaScanAngles(end)];
for j=1:numel(thetaArrivalAngles)
indx = find(thetaScanAngles >= thetaArrivalAngles(j), 1);
line(ax, [thetaScanAngles(indx) thetaScanAngles(indx)], ax.YLim,’LineWidth’, 1, ‘Color’, ‘r’, ‘LineStyle’, ‘–‘);
end
xlabel(ax, ‘theta’)
ylabel(ax, ‘dB’) digital signal processing MATLAB Answers — New Questions
SVPWM abnormal current under inductive load
I desing three phase inverter with SVPWM with matlab&simulink 2024a
It works perfectly under resistive load.
When I add 450VAR inductive load to 450W resistive load at 0,02 second, phase a and b currents shift up and phase c current shift down. why?
All loads is balanced. Why does current behavior like that? How can ı solve it?I desing three phase inverter with SVPWM with matlab&simulink 2024a
It works perfectly under resistive load.
When I add 450VAR inductive load to 450W resistive load at 0,02 second, phase a and b currents shift up and phase c current shift down. why?
All loads is balanced. Why does current behavior like that? How can ı solve it? I desing three phase inverter with SVPWM with matlab&simulink 2024a
It works perfectly under resistive load.
When I add 450VAR inductive load to 450W resistive load at 0,02 second, phase a and b currents shift up and phase c current shift down. why?
All loads is balanced. Why does current behavior like that? How can ı solve it? inductive load, svpwm, load MATLAB Answers — New Questions
Episode reward is too high to be true
My problem is that my reward function is well defined to be expected in a range of -80 to 80. Running through a lot of times of my environment step function and the step reward is working fine. Below is the sample graph of reward against each step when the action inputted for each step is fully randomised.
However, whenever I train it with my PPO agent, the episode reward will be absurbly high, as shown in the table below.
It’s an absurb episode reward value for a 45 steps per episode training. That just means every step reward is 187717.36/45 = 4171.5 average, which is impossible to happen.
Another problem is I can’t terminate the training by using the ‘stop training’ in the reinforcement learning training monitor. I can stop the training by pausing the matlab and the window will show that the training is stopped. However, the environment is still running for no reason despite the window said that it has stopped. My environment do keep popping cmd window for each step because it links to the external software and I used task kill to close the cmd. Not sure this is the cause. Spend days and still don’t know what caused it.
Any help is appreciated.My problem is that my reward function is well defined to be expected in a range of -80 to 80. Running through a lot of times of my environment step function and the step reward is working fine. Below is the sample graph of reward against each step when the action inputted for each step is fully randomised.
However, whenever I train it with my PPO agent, the episode reward will be absurbly high, as shown in the table below.
It’s an absurb episode reward value for a 45 steps per episode training. That just means every step reward is 187717.36/45 = 4171.5 average, which is impossible to happen.
Another problem is I can’t terminate the training by using the ‘stop training’ in the reinforcement learning training monitor. I can stop the training by pausing the matlab and the window will show that the training is stopped. However, the environment is still running for no reason despite the window said that it has stopped. My environment do keep popping cmd window for each step because it links to the external software and I used task kill to close the cmd. Not sure this is the cause. Spend days and still don’t know what caused it.
Any help is appreciated. My problem is that my reward function is well defined to be expected in a range of -80 to 80. Running through a lot of times of my environment step function and the step reward is working fine. Below is the sample graph of reward against each step when the action inputted for each step is fully randomised.
However, whenever I train it with my PPO agent, the episode reward will be absurbly high, as shown in the table below.
It’s an absurb episode reward value for a 45 steps per episode training. That just means every step reward is 187717.36/45 = 4171.5 average, which is impossible to happen.
Another problem is I can’t terminate the training by using the ‘stop training’ in the reinforcement learning training monitor. I can stop the training by pausing the matlab and the window will show that the training is stopped. However, the environment is still running for no reason despite the window said that it has stopped. My environment do keep popping cmd window for each step because it links to the external software and I used task kill to close the cmd. Not sure this is the cause. Spend days and still don’t know what caused it.
Any help is appreciated. reinforcement learning, machine learning, reinforcement learning toolbox, ppoagent MATLAB Answers — New Questions
“exportgraphics” lengthens the height of EPS
Hi, I am using MATLAB function "exportgraphics" to export some EPS files. I am facing following two problems.
There is an option for "exportgraphics" called "ContentType".
If I set "ContentType" to "vector", then EPS files cannot keep transparency of the figure object I create.
If I set "ContentType" to "image", then somehow EPS files will be lengthened in Y-axis so that the bottom part are missing.
Both above-mentioned problems do not exist for exporting PDF files by using exportgraphics.
Any comment helps!Hi, I am using MATLAB function "exportgraphics" to export some EPS files. I am facing following two problems.
There is an option for "exportgraphics" called "ContentType".
If I set "ContentType" to "vector", then EPS files cannot keep transparency of the figure object I create.
If I set "ContentType" to "image", then somehow EPS files will be lengthened in Y-axis so that the bottom part are missing.
Both above-mentioned problems do not exist for exporting PDF files by using exportgraphics.
Any comment helps! Hi, I am using MATLAB function "exportgraphics" to export some EPS files. I am facing following two problems.
There is an option for "exportgraphics" called "ContentType".
If I set "ContentType" to "vector", then EPS files cannot keep transparency of the figure object I create.
If I set "ContentType" to "image", then somehow EPS files will be lengthened in Y-axis so that the bottom part are missing.
Both above-mentioned problems do not exist for exporting PDF files by using exportgraphics.
Any comment helps! exportgraphics, eps, contenttype MATLAB Answers — New Questions
Decrease compilation time with mex using compiler cache (e.g. ccache in Linux)
I am using the Matlab codegen command quite often to decrease the runtime of my Matlab functions and compile them as mex. However, when working on my algorithm, I often need to recompile my functions in between my tests and validations. This takes up to 5min for complex functions which decreases my productivity.
Does anyone have experience using a compiler cache such as ccache (I am using Ubuntu 18.04) together with Matlab (R2021a)? I did a first attempt to implement this, but the compilation time did not really decrease, despite that ccache is used.
Workflow so far:
Install ccache (Ubuntu 18.04): sudo apt install ccache
use ccache for all compilers: sudo /usr/sbin/update-ccache-symlinks
call Matlab with ccache path: PATH="/usr/lib/ccache/:$PATH" matlab
check path in Matlab: !echo $PATH gives /usr/lib/ccache/:/home/username/bin:….
compile a function using the Matlab codegen command (with wrapper matlabfcn2mex)
That ccache is used can be seen in the buildLog.log file (in fcndir/codegen/mex/fcnname/build/glnxa64). Alle lines begin with /usr/lib/ccache/gcc instead of /usr/bin/gcc as before. The ccache statistics (ccache -s) gives increased values for "cache hit (direct)" and "cache hit (preprocessed)" after each call of codegen in Matlab. For my example file (6 DoF serial robot inverse kinematics using Newton Raphson) I still need around 120s, despite the file is not changed and should be fully in the cache. Without the cache the time is around the same. I would expect a drastic decrease of compilation time, as can be seen when using ccache+cmake e.g. in building a ROS workspace.
Any ideas or comments?I am using the Matlab codegen command quite often to decrease the runtime of my Matlab functions and compile them as mex. However, when working on my algorithm, I often need to recompile my functions in between my tests and validations. This takes up to 5min for complex functions which decreases my productivity.
Does anyone have experience using a compiler cache such as ccache (I am using Ubuntu 18.04) together with Matlab (R2021a)? I did a first attempt to implement this, but the compilation time did not really decrease, despite that ccache is used.
Workflow so far:
Install ccache (Ubuntu 18.04): sudo apt install ccache
use ccache for all compilers: sudo /usr/sbin/update-ccache-symlinks
call Matlab with ccache path: PATH="/usr/lib/ccache/:$PATH" matlab
check path in Matlab: !echo $PATH gives /usr/lib/ccache/:/home/username/bin:….
compile a function using the Matlab codegen command (with wrapper matlabfcn2mex)
That ccache is used can be seen in the buildLog.log file (in fcndir/codegen/mex/fcnname/build/glnxa64). Alle lines begin with /usr/lib/ccache/gcc instead of /usr/bin/gcc as before. The ccache statistics (ccache -s) gives increased values for "cache hit (direct)" and "cache hit (preprocessed)" after each call of codegen in Matlab. For my example file (6 DoF serial robot inverse kinematics using Newton Raphson) I still need around 120s, despite the file is not changed and should be fully in the cache. Without the cache the time is around the same. I would expect a drastic decrease of compilation time, as can be seen when using ccache+cmake e.g. in building a ROS workspace.
Any ideas or comments? I am using the Matlab codegen command quite often to decrease the runtime of my Matlab functions and compile them as mex. However, when working on my algorithm, I often need to recompile my functions in between my tests and validations. This takes up to 5min for complex functions which decreases my productivity.
Does anyone have experience using a compiler cache such as ccache (I am using Ubuntu 18.04) together with Matlab (R2021a)? I did a first attempt to implement this, but the compilation time did not really decrease, despite that ccache is used.
Workflow so far:
Install ccache (Ubuntu 18.04): sudo apt install ccache
use ccache for all compilers: sudo /usr/sbin/update-ccache-symlinks
call Matlab with ccache path: PATH="/usr/lib/ccache/:$PATH" matlab
check path in Matlab: !echo $PATH gives /usr/lib/ccache/:/home/username/bin:….
compile a function using the Matlab codegen command (with wrapper matlabfcn2mex)
That ccache is used can be seen in the buildLog.log file (in fcndir/codegen/mex/fcnname/build/glnxa64). Alle lines begin with /usr/lib/ccache/gcc instead of /usr/bin/gcc as before. The ccache statistics (ccache -s) gives increased values for "cache hit (direct)" and "cache hit (preprocessed)" after each call of codegen in Matlab. For my example file (6 DoF serial robot inverse kinematics using Newton Raphson) I still need around 120s, despite the file is not changed and should be fully in the cache. Without the cache the time is around the same. I would expect a drastic decrease of compilation time, as can be seen when using ccache+cmake e.g. in building a ROS workspace.
Any ideas or comments? matlab, mex, mex compiler, codegen, ccache, linux MATLAB Answers — New Questions
how to solve low-level graphics?
I want to slove the error about low-level graphics.
Could you help me?
Theta_Theory = linspace(D2, D1, 10000);
Velocity_Theory = linspace(-100,0,10000);
figure(1);
[Theta_Theory, Velocity_Theory] = meshgrid(Theta_Theory, Velocity_Theory);
x1 = sin(Theta_Theory);
y1 = -cos(Theta_Theory);
T = sqrt(2*abs(y1)/9.8);
target = 10;
S_z = x1 + abs(Velocity_Theory.*cos(Theta_Theory)).*T.’;
z = -abs(S_z -target);
h = pcolor(Theta_Theory, Velocity_Theory,z);
shading interp
set(h,’EdgeColor’,’none’,’linestyle’,’none’);
colorbar;
colormap(jet(256));I want to slove the error about low-level graphics.
Could you help me?
Theta_Theory = linspace(D2, D1, 10000);
Velocity_Theory = linspace(-100,0,10000);
figure(1);
[Theta_Theory, Velocity_Theory] = meshgrid(Theta_Theory, Velocity_Theory);
x1 = sin(Theta_Theory);
y1 = -cos(Theta_Theory);
T = sqrt(2*abs(y1)/9.8);
target = 10;
S_z = x1 + abs(Velocity_Theory.*cos(Theta_Theory)).*T.’;
z = -abs(S_z -target);
h = pcolor(Theta_Theory, Velocity_Theory,z);
shading interp
set(h,’EdgeColor’,’none’,’linestyle’,’none’);
colorbar;
colormap(jet(256)); I want to slove the error about low-level graphics.
Could you help me?
Theta_Theory = linspace(D2, D1, 10000);
Velocity_Theory = linspace(-100,0,10000);
figure(1);
[Theta_Theory, Velocity_Theory] = meshgrid(Theta_Theory, Velocity_Theory);
x1 = sin(Theta_Theory);
y1 = -cos(Theta_Theory);
T = sqrt(2*abs(y1)/9.8);
target = 10;
S_z = x1 + abs(Velocity_Theory.*cos(Theta_Theory)).*T.’;
z = -abs(S_z -target);
h = pcolor(Theta_Theory, Velocity_Theory,z);
shading interp
set(h,’EdgeColor’,’none’,’linestyle’,’none’);
colorbar;
colormap(jet(256)); matlab, low-level, graphics MATLAB Answers — New Questions
LNG liquid to gas phase change simulation Simscape
Good day everyone,
I want to simulate LNG to gas system (liquid phase to gas phase). Currently, I am using Thermal Liquid library (I am considering Two-phase library as well) to show liquid phase of LNG but I am not able to vaporise liquid into gas phase.
(LNG liquid phase part in simulation)
(In next step, I need to simulate LNG tank where high pressure LNG and partial natural gas stored in the same tank. I am thinking to use Tank (G-TL) block)
In liquid-to-gas part, I need to heat liquid LNG with a heat source (heating water) to increase temperature of LNG forcing to evaporate. After this step, LNG will be transformed into gas form. And I would like to clearly show in which phase LNG is (gas phase to be shown with gas library).
(Brief configuration of Liquid to Gas LNG transformation. TL(or 2P) library to Gas library)
Can you please guide me in liquid to gas phase LNG simulation?
Thanks in advance.Good day everyone,
I want to simulate LNG to gas system (liquid phase to gas phase). Currently, I am using Thermal Liquid library (I am considering Two-phase library as well) to show liquid phase of LNG but I am not able to vaporise liquid into gas phase.
(LNG liquid phase part in simulation)
(In next step, I need to simulate LNG tank where high pressure LNG and partial natural gas stored in the same tank. I am thinking to use Tank (G-TL) block)
In liquid-to-gas part, I need to heat liquid LNG with a heat source (heating water) to increase temperature of LNG forcing to evaporate. After this step, LNG will be transformed into gas form. And I would like to clearly show in which phase LNG is (gas phase to be shown with gas library).
(Brief configuration of Liquid to Gas LNG transformation. TL(or 2P) library to Gas library)
Can you please guide me in liquid to gas phase LNG simulation?
Thanks in advance. Good day everyone,
I want to simulate LNG to gas system (liquid phase to gas phase). Currently, I am using Thermal Liquid library (I am considering Two-phase library as well) to show liquid phase of LNG but I am not able to vaporise liquid into gas phase.
(LNG liquid phase part in simulation)
(In next step, I need to simulate LNG tank where high pressure LNG and partial natural gas stored in the same tank. I am thinking to use Tank (G-TL) block)
In liquid-to-gas part, I need to heat liquid LNG with a heat source (heating water) to increase temperature of LNG forcing to evaporate. After this step, LNG will be transformed into gas form. And I would like to clearly show in which phase LNG is (gas phase to be shown with gas library).
(Brief configuration of Liquid to Gas LNG transformation. TL(or 2P) library to Gas library)
Can you please guide me in liquid to gas phase LNG simulation?
Thanks in advance. lng, natural gas, gas, simulink, simscape MATLAB Answers — New Questions
Reading and storing data efficiently – from spreadsheet to cell array
Hello everybody,
I am wondering what is the most efficient way to read data from a spreadsheet file and store it in the most efficient data structure. The question is general, but I also provide the way I do to welcome any suggestion.
I read data from very long spreadsheet (hundred-of-thousands rows for each sheet), and I need to store only one column for each sheet.
for j = 1:12
Data = readtable(filename, ‘Sheet’, j+1, ‘ReadVariableNames’, false);
Data = table2array(Data(:,3));
Data = rmmissing(Data);
filenameOutput = [outputDir, indexName{i}, monthName{j}, ‘.mat’];
save(filenameOutput, ‘Data’);
end
What is the most efficient way to do it?
And what about if I want to store the data in a cell format (that is, a N(i)x1 cell where N(i) is the variable length of each column)?
Thank you very much in advanceHello everybody,
I am wondering what is the most efficient way to read data from a spreadsheet file and store it in the most efficient data structure. The question is general, but I also provide the way I do to welcome any suggestion.
I read data from very long spreadsheet (hundred-of-thousands rows for each sheet), and I need to store only one column for each sheet.
for j = 1:12
Data = readtable(filename, ‘Sheet’, j+1, ‘ReadVariableNames’, false);
Data = table2array(Data(:,3));
Data = rmmissing(Data);
filenameOutput = [outputDir, indexName{i}, monthName{j}, ‘.mat’];
save(filenameOutput, ‘Data’);
end
What is the most efficient way to do it?
And what about if I want to store the data in a cell format (that is, a N(i)x1 cell where N(i) is the variable length of each column)?
Thank you very much in advance Hello everybody,
I am wondering what is the most efficient way to read data from a spreadsheet file and store it in the most efficient data structure. The question is general, but I also provide the way I do to welcome any suggestion.
I read data from very long spreadsheet (hundred-of-thousands rows for each sheet), and I need to store only one column for each sheet.
for j = 1:12
Data = readtable(filename, ‘Sheet’, j+1, ‘ReadVariableNames’, false);
Data = table2array(Data(:,3));
Data = rmmissing(Data);
filenameOutput = [outputDir, indexName{i}, monthName{j}, ‘.mat’];
save(filenameOutput, ‘Data’);
end
What is the most efficient way to do it?
And what about if I want to store the data in a cell format (that is, a N(i)x1 cell where N(i) is the variable length of each column)?
Thank you very much in advance readtable MATLAB Answers — New Questions
Parse Error when using Syms
Hi everyone,
For an assignment I have to solve a system of ODE’s given the matrix DE using the Adams-Bashforth method and compare my numerical approximation to the exact one. To find the exact solution, I want to use dsolve, but every I run my code I get the error message ‘Unexpected MATLAB expression’ and then ‘Parse Error at Y_2(t): Usage might be invalid MATLAB syntax’. I am using MATLABR2017.
Does anyone know what the issue is?
function Y_exact = exact_soln(time)
%Actual solution to the system:
A = [-20, 10, 0, 0;…
10, -20, 10, 0;…
0, 10, -20, 10;…
0, 0, 10, -20];
y_0 = ones(4,1);
syms = Y_1(x) Y_2(x) Y_3(x) Y_4(x)
Y = [Y_1; Y_2; Y_3; Y_4];
odes = diff(Y) == A*Y;
[Y_1Sol(x), Y_2Sol(x), Y_3Sol(x), Y_4Sol(x)] = dsolve(odes,y_0);
Y_exact = [double(Y_1Sol(time));…
double(Y_2Sol(time));…
double(Y_3Sol(time));…
double(Y_4Sol(time))];
endHi everyone,
For an assignment I have to solve a system of ODE’s given the matrix DE using the Adams-Bashforth method and compare my numerical approximation to the exact one. To find the exact solution, I want to use dsolve, but every I run my code I get the error message ‘Unexpected MATLAB expression’ and then ‘Parse Error at Y_2(t): Usage might be invalid MATLAB syntax’. I am using MATLABR2017.
Does anyone know what the issue is?
function Y_exact = exact_soln(time)
%Actual solution to the system:
A = [-20, 10, 0, 0;…
10, -20, 10, 0;…
0, 10, -20, 10;…
0, 0, 10, -20];
y_0 = ones(4,1);
syms = Y_1(x) Y_2(x) Y_3(x) Y_4(x)
Y = [Y_1; Y_2; Y_3; Y_4];
odes = diff(Y) == A*Y;
[Y_1Sol(x), Y_2Sol(x), Y_3Sol(x), Y_4Sol(x)] = dsolve(odes,y_0);
Y_exact = [double(Y_1Sol(time));…
double(Y_2Sol(time));…
double(Y_3Sol(time));…
double(Y_4Sol(time))];
end Hi everyone,
For an assignment I have to solve a system of ODE’s given the matrix DE using the Adams-Bashforth method and compare my numerical approximation to the exact one. To find the exact solution, I want to use dsolve, but every I run my code I get the error message ‘Unexpected MATLAB expression’ and then ‘Parse Error at Y_2(t): Usage might be invalid MATLAB syntax’. I am using MATLABR2017.
Does anyone know what the issue is?
function Y_exact = exact_soln(time)
%Actual solution to the system:
A = [-20, 10, 0, 0;…
10, -20, 10, 0;…
0, 10, -20, 10;…
0, 0, 10, -20];
y_0 = ones(4,1);
syms = Y_1(x) Y_2(x) Y_3(x) Y_4(x)
Y = [Y_1; Y_2; Y_3; Y_4];
odes = diff(Y) == A*Y;
[Y_1Sol(x), Y_2Sol(x), Y_3Sol(x), Y_4Sol(x)] = dsolve(odes,y_0);
Y_exact = [double(Y_1Sol(time));…
double(Y_2Sol(time));…
double(Y_3Sol(time));…
double(Y_4Sol(time))];
end dsolve, syms, parse error, invalid matlab syntax, unexpected matlab syntax, diff, odes MATLAB Answers — New Questions
failed to generate java files when using libarary package
error during packaging:
the log file:
copy the "following command"and run in cmd:
(the error messge above means that the link16.java is not found.)
It seems that the java files are compiled by javac while they havn’t yet been generated. I can’t figure out why, as the packaging worked well last day, and after I added more MEX files, it failed like above. Now even a new packaging project can not package successfully. Additionally, the "Files required for your libarary to run" list contains several P-coded files, could these files have caused it?
I’ll be appreciate it if someone can help me to figure out what cause the confuing error.error during packaging:
the log file:
copy the "following command"and run in cmd:
(the error messge above means that the link16.java is not found.)
It seems that the java files are compiled by javac while they havn’t yet been generated. I can’t figure out why, as the packaging worked well last day, and after I added more MEX files, it failed like above. Now even a new packaging project can not package successfully. Additionally, the "Files required for your libarary to run" list contains several P-coded files, could these files have caused it?
I’ll be appreciate it if someone can help me to figure out what cause the confuing error. error during packaging:
the log file:
copy the "following command"and run in cmd:
(the error messge above means that the link16.java is not found.)
It seems that the java files are compiled by javac while they havn’t yet been generated. I can’t figure out why, as the packaging worked well last day, and after I added more MEX files, it failed like above. Now even a new packaging project can not package successfully. Additionally, the "Files required for your libarary to run" list contains several P-coded files, could these files have caused it?
I’ll be appreciate it if someone can help me to figure out what cause the confuing error. matlab, java package, p-coded MATLAB Answers — New Questions
How to plot multiple graphs in one figure ?
I have two codes. Each code has four graphs. I want to plot two graphs in one figure. For example: Dead nodes vs Round graph of two should be in one figure. In the same way other graphs also. I tried hold on function but still not getting. How to merge the two codes in order to get the graphs ?I have two codes. Each code has four graphs. I want to plot two graphs in one figure. For example: Dead nodes vs Round graph of two should be in one figure. In the same way other graphs also. I tried hold on function but still not getting. How to merge the two codes in order to get the graphs ? I have two codes. Each code has four graphs. I want to plot two graphs in one figure. For example: Dead nodes vs Round graph of two should be in one figure. In the same way other graphs also. I tried hold on function but still not getting. How to merge the two codes in order to get the graphs ? subplot, tiledlayout, figure, multiple, axes MATLAB Answers — New Questions
Error while trying to get connected to a server
Hi,
While using the matlab command ib = ibtws(”,7496); to try to get connected to the software Interactive Brokers, I got this answer from matlab:
Error using actxserver (line 93)
Server creation failed. Invalid ProgID ‘TWS.TwsCtrl.1’.
Error in ibtws (line 37)
x.Handle = actxserver(‘TWS.TwsCtrl.1’);
Could you give me an answer of how to cope with this issue ?Hi,
While using the matlab command ib = ibtws(”,7496); to try to get connected to the software Interactive Brokers, I got this answer from matlab:
Error using actxserver (line 93)
Server creation failed. Invalid ProgID ‘TWS.TwsCtrl.1’.
Error in ibtws (line 37)
x.Handle = actxserver(‘TWS.TwsCtrl.1’);
Could you give me an answer of how to cope with this issue ? Hi,
While using the matlab command ib = ibtws(”,7496); to try to get connected to the software Interactive Brokers, I got this answer from matlab:
Error using actxserver (line 93)
Server creation failed. Invalid ProgID ‘TWS.TwsCtrl.1’.
Error in ibtws (line 37)
x.Handle = actxserver(‘TWS.TwsCtrl.1’);
Could you give me an answer of how to cope with this issue ? connection to server MATLAB Answers — New Questions
Code Generation for model Referencing
Hello,
I build a model using model referencing.Then i generated the code using Embedded Coder.
As there were two models -parent and child model.So two different files c files are created in two different file structures(as there are two different model)
Is there anyway i can generate code for both model (parent and chid) in same folder?Hello,
I build a model using model referencing.Then i generated the code using Embedded Coder.
As there were two models -parent and child model.So two different files c files are created in two different file structures(as there are two different model)
Is there anyway i can generate code for both model (parent and chid) in same folder? Hello,
I build a model using model referencing.Then i generated the code using Embedded Coder.
As there were two models -parent and child model.So two different files c files are created in two different file structures(as there are two different model)
Is there anyway i can generate code for both model (parent and chid) in same folder? embedded coder, simulink, matlab, model, modelreference MATLAB Answers — New Questions
How to initialize the workspace for a simulink model from a python script using the matlab engine
Hi everyone! I’ve connected a python script to a simulink model as explained in this tutorial https://medium.com/@soutrikbandyopadhyay/controlling-a-simulink-model-by-a-python-controller-2b67bde744ee. What I would like to know now is: my simulink model calls some variables from the workspace, so is there a way to initialize the workspace using the matlab engine in python?Hi everyone! I’ve connected a python script to a simulink model as explained in this tutorial https://medium.com/@soutrikbandyopadhyay/controlling-a-simulink-model-by-a-python-controller-2b67bde744ee. What I would like to know now is: my simulink model calls some variables from the workspace, so is there a way to initialize the workspace using the matlab engine in python? Hi everyone! I’ve connected a python script to a simulink model as explained in this tutorial https://medium.com/@soutrikbandyopadhyay/controlling-a-simulink-model-by-a-python-controller-2b67bde744ee. What I would like to know now is: my simulink model calls some variables from the workspace, so is there a way to initialize the workspace using the matlab engine in python? python, simulink, matlab engine MATLAB Answers — New Questions