Month: January 2025
How can I write a sparse matrix’s non-zero values and the corresponding row and column information to a text file?
I define a sparse identity matrix, using the SPEYE command as follows:
A = speye(5)
and receive the following output:
A =
(1,1) 1
(2,2) 1
(3,3) 1
(4,4) 1
(5,5) 1
I would like to write the non-zero elements as well as the row and column information corresponding to the non-zero elements to a text file.I define a sparse identity matrix, using the SPEYE command as follows:
A = speye(5)
and receive the following output:
A =
(1,1) 1
(2,2) 1
(3,3) 1
(4,4) 1
(5,5) 1
I would like to write the non-zero elements as well as the row and column information corresponding to the non-zero elements to a text file. I define a sparse identity matrix, using the SPEYE command as follows:
A = speye(5)
and receive the following output:
A =
(1,1) 1
(2,2) 1
(3,3) 1
(4,4) 1
(5,5) 1
I would like to write the non-zero elements as well as the row and column information corresponding to the non-zero elements to a text file. MATLAB Answers — New Questions
Can I use figures generated by view(net) command freely in my thesis and academic papers?
Hello,
I would like to know if I can freely use the figures generated by the view(net) command in my thesis (also in academic papers).
If not, what is the correct way to use them appropriately?
Or
Thank you.Hello,
I would like to know if I can freely use the figures generated by the view(net) command in my thesis (also in academic papers).
If not, what is the correct way to use them appropriately?
Or
Thank you. Hello,
I would like to know if I can freely use the figures generated by the view(net) command in my thesis (also in academic papers).
If not, what is the correct way to use them appropriately?
Or
Thank you. copyright MATLAB Answers — New Questions
The output of ‘chart XYZ’ cannot be logged because this block is a Simulink function within Stateflow or a MATLAB Function block. But no signal is logged.
I’m using Matlab/Simulink 2018b and my model is not runnable. The following error appears: The output of ‘path of chart XYZ’ cannot be logged because this block is a Simulink function within Stateflow or a MATLAB Function block. Even though no signal is logged. I don’t know how to localize the issue. Befor puschen the model to the lib it was working fine. How can I fix the issue?I’m using Matlab/Simulink 2018b and my model is not runnable. The following error appears: The output of ‘path of chart XYZ’ cannot be logged because this block is a Simulink function within Stateflow or a MATLAB Function block. Even though no signal is logged. I don’t know how to localize the issue. Befor puschen the model to the lib it was working fine. How can I fix the issue? I’m using Matlab/Simulink 2018b and my model is not runnable. The following error appears: The output of ‘path of chart XYZ’ cannot be logged because this block is a Simulink function within Stateflow or a MATLAB Function block. Even though no signal is logged. I don’t know how to localize the issue. Befor puschen the model to the lib it was working fine. How can I fix the issue? output cannot be logged MATLAB Answers — New Questions
View into a Simscapeblock
Hi all,
I have a question about Simscape blocks. In particular, I am interested in the block “Spark Ignition Engine”.
It performs various calculations related to the operation of a four-stroke engine with external ignition.
I would like to know what formulas are behind the block’s calculations so that I can better interpret the results.
The “Description” submenu allows you to access the block’s source code.
However, this code only shows what you see in Simulink’s graphical interface.
Is there a way to access the mathematical formulas that the block uses to perform its calculations?
The following command takes you to the example project in question:
openExample(‘sdl/SingleCylinderSparkIgnitionEngineExample’)
I would be very happy to receive a reply.
Kind regards,
FlorianHi all,
I have a question about Simscape blocks. In particular, I am interested in the block “Spark Ignition Engine”.
It performs various calculations related to the operation of a four-stroke engine with external ignition.
I would like to know what formulas are behind the block’s calculations so that I can better interpret the results.
The “Description” submenu allows you to access the block’s source code.
However, this code only shows what you see in Simulink’s graphical interface.
Is there a way to access the mathematical formulas that the block uses to perform its calculations?
The following command takes you to the example project in question:
openExample(‘sdl/SingleCylinderSparkIgnitionEngineExample’)
I would be very happy to receive a reply.
Kind regards,
Florian Hi all,
I have a question about Simscape blocks. In particular, I am interested in the block “Spark Ignition Engine”.
It performs various calculations related to the operation of a four-stroke engine with external ignition.
I would like to know what formulas are behind the block’s calculations so that I can better interpret the results.
The “Description” submenu allows you to access the block’s source code.
However, this code only shows what you see in Simulink’s graphical interface.
Is there a way to access the mathematical formulas that the block uses to perform its calculations?
The following command takes you to the example project in question:
openExample(‘sdl/SingleCylinderSparkIgnitionEngineExample’)
I would be very happy to receive a reply.
Kind regards,
Florian simscape, spark ignition engine, singlecylindersparkignitionengineexample MATLAB Answers — New Questions
Horizontal Freestream Flow Issues With Symbolic Math Toolbox
I am attempting to plot stictly horizontal freestream flow using fcontour and the Symbolic Math toolbox. A few days ago I was able to successfully achieve this with the code below. However, starting last night whenever I run the script the "symbolic method" produces vertical contour lines that indicate stricty vertical freestram flow. I have gone back to the original code to ensure nothing I changed in the script had an impact, but the issue still remains. I have included an image of the incorrect plot (from the symbolic method) vs. the correct plot (from the numerical method) to better illustrate the problem. I would love some guidance on what to try and fix this strange issue.
clear
clc
% use the symbolic method to create the stream function for freestream flow
% and plot it
syms xs ys
Uval = 1;
Vval = 0;
psi_fs = Uval*ys – Vval*xs;
figure(4)
fcontour(psi_fs,[-3 3 -5 5],’k’); %’k’ makes all the lines black
% use the numerical method to create the stream function for freestream
% flow and plot it
xlocs = [-3:.1:3]; % you can use linspace for this
ylocs = [-3:.1:3];
% make the grid of points x horizontal, y vertical
[xmat,ymat] = meshgrid(xlocs,ylocs);
psi_vals_fs = Uval*ymat – Vval*xmat;
figure(5)
contour(xmat, ymat, psi_vals_fs,’k’) % ‘k’ makes all the lines blackI am attempting to plot stictly horizontal freestream flow using fcontour and the Symbolic Math toolbox. A few days ago I was able to successfully achieve this with the code below. However, starting last night whenever I run the script the "symbolic method" produces vertical contour lines that indicate stricty vertical freestram flow. I have gone back to the original code to ensure nothing I changed in the script had an impact, but the issue still remains. I have included an image of the incorrect plot (from the symbolic method) vs. the correct plot (from the numerical method) to better illustrate the problem. I would love some guidance on what to try and fix this strange issue.
clear
clc
% use the symbolic method to create the stream function for freestream flow
% and plot it
syms xs ys
Uval = 1;
Vval = 0;
psi_fs = Uval*ys – Vval*xs;
figure(4)
fcontour(psi_fs,[-3 3 -5 5],’k’); %’k’ makes all the lines black
% use the numerical method to create the stream function for freestream
% flow and plot it
xlocs = [-3:.1:3]; % you can use linspace for this
ylocs = [-3:.1:3];
% make the grid of points x horizontal, y vertical
[xmat,ymat] = meshgrid(xlocs,ylocs);
psi_vals_fs = Uval*ymat – Vval*xmat;
figure(5)
contour(xmat, ymat, psi_vals_fs,’k’) % ‘k’ makes all the lines black I am attempting to plot stictly horizontal freestream flow using fcontour and the Symbolic Math toolbox. A few days ago I was able to successfully achieve this with the code below. However, starting last night whenever I run the script the "symbolic method" produces vertical contour lines that indicate stricty vertical freestram flow. I have gone back to the original code to ensure nothing I changed in the script had an impact, but the issue still remains. I have included an image of the incorrect plot (from the symbolic method) vs. the correct plot (from the numerical method) to better illustrate the problem. I would love some guidance on what to try and fix this strange issue.
clear
clc
% use the symbolic method to create the stream function for freestream flow
% and plot it
syms xs ys
Uval = 1;
Vval = 0;
psi_fs = Uval*ys – Vval*xs;
figure(4)
fcontour(psi_fs,[-3 3 -5 5],’k’); %’k’ makes all the lines black
% use the numerical method to create the stream function for freestream
% flow and plot it
xlocs = [-3:.1:3]; % you can use linspace for this
ylocs = [-3:.1:3];
% make the grid of points x horizontal, y vertical
[xmat,ymat] = meshgrid(xlocs,ylocs);
psi_vals_fs = Uval*ymat – Vval*xmat;
figure(5)
contour(xmat, ymat, psi_vals_fs,’k’) % ‘k’ makes all the lines black fcontour, symbolic MATLAB Answers — New Questions
Why does the MathWorks Product Installer get stuck on selecting the destination folder?
Why does the MathWorks Product Installer get stuck on selecting the destination folder?Why does the MathWorks Product Installer get stuck on selecting the destination folder? Why does the MathWorks Product Installer get stuck on selecting the destination folder? MATLAB Answers — New Questions
Non linear fitting and parametric optimization with genetic algorithm
I have a constitutive model with 4 parameters to fit to experimental stress vs strain data. Before implementing the GA, I tried lsqnonlin (with and without multistart), but one of the main problems is that the algorithm often tends to assign bound values to the optimised parameters. To the first parameter, which is larger than the others, it assigns the upper bound, to the second and third it assigns the lower bounds. Plotting the best individuals over time, it appears that the ga spans little between the solutions, and the optimisation seems to be biased towards the first parameter.
I am using the uniaxial model proposed by Dong, and have rechecked the correctness of the model form several times. Below is the main containing the ga and my error function. Any help is welcome, thank you
%CHANGE LINE 3 TO SELECT THE PATCH
%CHANGE LINES 9 AND 10 TO SELECT THE SPECIMEN
clc; clear all;close all;
load ("data_11122.mat"); % change lot number if necessary
clearvars -except data
%Model requires lambda= x/x0 instead of epsilon: calculate lambda
% from exp data and store in data struct
stress=data(6).stress; %change index to change dogbone if necessary
stress=stress/max(stress);
strain=data(6).strain; %change index to change dogbone if necessary
p_initial=[50 25 5 .5]*10e-3;
a0=[1 0 0];
%vincoli su zeta imposti da dong ( zeta tra 0 e 1 )
lb=[0 0 0 0]; %% AGGIUSTA UNITA DIN MISURA
ub=[650 98 35 1];
%ottimizzazione non lineare con metodo least square ( like Dong )
options = optimoptions(‘ga’, ‘Display’, ‘iter’, ‘PopulationSize’, 100, ‘MaxGenerations’, 200, ‘UseParallel’, true,’NonlinearConstraintAlgorithm’,’penalty’,’PlotFcn’,’gaplotbestindiv’,’InitialPopulationMatrix’,p_initial);
nvars=4;
[p_opt, fval, exitflag, output] = ga(@(p)(error_function(p, strain, stress)), nvars, [], [], [], [], lb, ub, [], options);
%check plot e ricostruzione del modello con i parametri ottimizzati
c = p_opt(1); % c
k1 = p_opt(2); % k1
k2 = p_opt(3); % k2
zeta = p_opt(4); % zeta
for i=1:length(strain)
sigma_calculated(i)=c*(strain(i)^2) + 2*strain(i)^2*k1*((strain(i)^2-1)*(i-zeta)^2*exp(k2*(strain(i)^2-1)^2*(1-zeta)^2));
end
% for i=1:length(strain)
% f = [strain(i) 0 0; %deformation gradient for each value of strain
% 0 1/sqrt(strain(i)) 0;
% 0 0 1/sqrt(strain(i))];
% C = f .* f’; % Calcola il tensore di Cauchy-Green
% prodot = a0 .* a0′;
% I4 = sum(sum(C .* prodot)); % calcolo invariante di C
% I = eye(3); % Matrice identità
%
% sigma= f*c*I*f’ + 2*f*(k1 * (1 – zeta)^2 * (I4 – 1) * (exp(k2 * ((1 – zeta) * (I4 – 1))^2)) * prodot)*f’;
%
% sigma_calculated(i)= sigma(1,1); %componente xx
% end
figure()
plot (strain,stress);
hold on
plot(strain, sigma_calculated,’r’);
legend (‘experimental’, ‘model’,’Location’, ‘northwest’);
function error = error_function(p,strain,stress)
sigma_calculated = zeros(length(strain), 1);
for i = 2:length(strain) %avoiding first value=0;
% f = [strain(i) 0 0; %deformation gradient
% 0 1/sqrt(strain(i)) 0;
% 0 0 1/sqrt(strain(i))];
% C = f .* f’; % tensore di Cauchy-Green
% prodot = a0 .* a0′;
% I4 = a0′ .* C .* a0; % calcolo IV invariante di C
% I = eye(3);
%
% sigma= f*p(1)*I*f’ + 2*f*(p(2) * (1 – p(4))^2 * (I4 – 1) * (exp(p(3) * ((1 – p(4)) * (I4 – 1))^2)) * prodot)*f’;
%
%
% sigma_calculated(i)= sigma(1,1); %componente xx
sigma_calculated(i)=p(1)*(strain(i)^2) + 2*strain(i)^2*p(2)*((strain(i)^2-1)*(i-p(4))^2*exp(p(3)*(strain(i)^2-1)^2*(1-p(4))^2));
end
error= sum((sigma_calculated-stress).^2) ; %/sum(stress).^2; % Somma dei quadrati delle differenze
%aggiungere normalizzazione rispetto allo stress( guardare script marta calcolo error )
endI have a constitutive model with 4 parameters to fit to experimental stress vs strain data. Before implementing the GA, I tried lsqnonlin (with and without multistart), but one of the main problems is that the algorithm often tends to assign bound values to the optimised parameters. To the first parameter, which is larger than the others, it assigns the upper bound, to the second and third it assigns the lower bounds. Plotting the best individuals over time, it appears that the ga spans little between the solutions, and the optimisation seems to be biased towards the first parameter.
I am using the uniaxial model proposed by Dong, and have rechecked the correctness of the model form several times. Below is the main containing the ga and my error function. Any help is welcome, thank you
%CHANGE LINE 3 TO SELECT THE PATCH
%CHANGE LINES 9 AND 10 TO SELECT THE SPECIMEN
clc; clear all;close all;
load ("data_11122.mat"); % change lot number if necessary
clearvars -except data
%Model requires lambda= x/x0 instead of epsilon: calculate lambda
% from exp data and store in data struct
stress=data(6).stress; %change index to change dogbone if necessary
stress=stress/max(stress);
strain=data(6).strain; %change index to change dogbone if necessary
p_initial=[50 25 5 .5]*10e-3;
a0=[1 0 0];
%vincoli su zeta imposti da dong ( zeta tra 0 e 1 )
lb=[0 0 0 0]; %% AGGIUSTA UNITA DIN MISURA
ub=[650 98 35 1];
%ottimizzazione non lineare con metodo least square ( like Dong )
options = optimoptions(‘ga’, ‘Display’, ‘iter’, ‘PopulationSize’, 100, ‘MaxGenerations’, 200, ‘UseParallel’, true,’NonlinearConstraintAlgorithm’,’penalty’,’PlotFcn’,’gaplotbestindiv’,’InitialPopulationMatrix’,p_initial);
nvars=4;
[p_opt, fval, exitflag, output] = ga(@(p)(error_function(p, strain, stress)), nvars, [], [], [], [], lb, ub, [], options);
%check plot e ricostruzione del modello con i parametri ottimizzati
c = p_opt(1); % c
k1 = p_opt(2); % k1
k2 = p_opt(3); % k2
zeta = p_opt(4); % zeta
for i=1:length(strain)
sigma_calculated(i)=c*(strain(i)^2) + 2*strain(i)^2*k1*((strain(i)^2-1)*(i-zeta)^2*exp(k2*(strain(i)^2-1)^2*(1-zeta)^2));
end
% for i=1:length(strain)
% f = [strain(i) 0 0; %deformation gradient for each value of strain
% 0 1/sqrt(strain(i)) 0;
% 0 0 1/sqrt(strain(i))];
% C = f .* f’; % Calcola il tensore di Cauchy-Green
% prodot = a0 .* a0′;
% I4 = sum(sum(C .* prodot)); % calcolo invariante di C
% I = eye(3); % Matrice identità
%
% sigma= f*c*I*f’ + 2*f*(k1 * (1 – zeta)^2 * (I4 – 1) * (exp(k2 * ((1 – zeta) * (I4 – 1))^2)) * prodot)*f’;
%
% sigma_calculated(i)= sigma(1,1); %componente xx
% end
figure()
plot (strain,stress);
hold on
plot(strain, sigma_calculated,’r’);
legend (‘experimental’, ‘model’,’Location’, ‘northwest’);
function error = error_function(p,strain,stress)
sigma_calculated = zeros(length(strain), 1);
for i = 2:length(strain) %avoiding first value=0;
% f = [strain(i) 0 0; %deformation gradient
% 0 1/sqrt(strain(i)) 0;
% 0 0 1/sqrt(strain(i))];
% C = f .* f’; % tensore di Cauchy-Green
% prodot = a0 .* a0′;
% I4 = a0′ .* C .* a0; % calcolo IV invariante di C
% I = eye(3);
%
% sigma= f*p(1)*I*f’ + 2*f*(p(2) * (1 – p(4))^2 * (I4 – 1) * (exp(p(3) * ((1 – p(4)) * (I4 – 1))^2)) * prodot)*f’;
%
%
% sigma_calculated(i)= sigma(1,1); %componente xx
sigma_calculated(i)=p(1)*(strain(i)^2) + 2*strain(i)^2*p(2)*((strain(i)^2-1)*(i-p(4))^2*exp(p(3)*(strain(i)^2-1)^2*(1-p(4))^2));
end
error= sum((sigma_calculated-stress).^2) ; %/sum(stress).^2; % Somma dei quadrati delle differenze
%aggiungere normalizzazione rispetto allo stress( guardare script marta calcolo error )
end I have a constitutive model with 4 parameters to fit to experimental stress vs strain data. Before implementing the GA, I tried lsqnonlin (with and without multistart), but one of the main problems is that the algorithm often tends to assign bound values to the optimised parameters. To the first parameter, which is larger than the others, it assigns the upper bound, to the second and third it assigns the lower bounds. Plotting the best individuals over time, it appears that the ga spans little between the solutions, and the optimisation seems to be biased towards the first parameter.
I am using the uniaxial model proposed by Dong, and have rechecked the correctness of the model form several times. Below is the main containing the ga and my error function. Any help is welcome, thank you
%CHANGE LINE 3 TO SELECT THE PATCH
%CHANGE LINES 9 AND 10 TO SELECT THE SPECIMEN
clc; clear all;close all;
load ("data_11122.mat"); % change lot number if necessary
clearvars -except data
%Model requires lambda= x/x0 instead of epsilon: calculate lambda
% from exp data and store in data struct
stress=data(6).stress; %change index to change dogbone if necessary
stress=stress/max(stress);
strain=data(6).strain; %change index to change dogbone if necessary
p_initial=[50 25 5 .5]*10e-3;
a0=[1 0 0];
%vincoli su zeta imposti da dong ( zeta tra 0 e 1 )
lb=[0 0 0 0]; %% AGGIUSTA UNITA DIN MISURA
ub=[650 98 35 1];
%ottimizzazione non lineare con metodo least square ( like Dong )
options = optimoptions(‘ga’, ‘Display’, ‘iter’, ‘PopulationSize’, 100, ‘MaxGenerations’, 200, ‘UseParallel’, true,’NonlinearConstraintAlgorithm’,’penalty’,’PlotFcn’,’gaplotbestindiv’,’InitialPopulationMatrix’,p_initial);
nvars=4;
[p_opt, fval, exitflag, output] = ga(@(p)(error_function(p, strain, stress)), nvars, [], [], [], [], lb, ub, [], options);
%check plot e ricostruzione del modello con i parametri ottimizzati
c = p_opt(1); % c
k1 = p_opt(2); % k1
k2 = p_opt(3); % k2
zeta = p_opt(4); % zeta
for i=1:length(strain)
sigma_calculated(i)=c*(strain(i)^2) + 2*strain(i)^2*k1*((strain(i)^2-1)*(i-zeta)^2*exp(k2*(strain(i)^2-1)^2*(1-zeta)^2));
end
% for i=1:length(strain)
% f = [strain(i) 0 0; %deformation gradient for each value of strain
% 0 1/sqrt(strain(i)) 0;
% 0 0 1/sqrt(strain(i))];
% C = f .* f’; % Calcola il tensore di Cauchy-Green
% prodot = a0 .* a0′;
% I4 = sum(sum(C .* prodot)); % calcolo invariante di C
% I = eye(3); % Matrice identità
%
% sigma= f*c*I*f’ + 2*f*(k1 * (1 – zeta)^2 * (I4 – 1) * (exp(k2 * ((1 – zeta) * (I4 – 1))^2)) * prodot)*f’;
%
% sigma_calculated(i)= sigma(1,1); %componente xx
% end
figure()
plot (strain,stress);
hold on
plot(strain, sigma_calculated,’r’);
legend (‘experimental’, ‘model’,’Location’, ‘northwest’);
function error = error_function(p,strain,stress)
sigma_calculated = zeros(length(strain), 1);
for i = 2:length(strain) %avoiding first value=0;
% f = [strain(i) 0 0; %deformation gradient
% 0 1/sqrt(strain(i)) 0;
% 0 0 1/sqrt(strain(i))];
% C = f .* f’; % tensore di Cauchy-Green
% prodot = a0 .* a0′;
% I4 = a0′ .* C .* a0; % calcolo IV invariante di C
% I = eye(3);
%
% sigma= f*p(1)*I*f’ + 2*f*(p(2) * (1 – p(4))^2 * (I4 – 1) * (exp(p(3) * ((1 – p(4)) * (I4 – 1))^2)) * prodot)*f’;
%
%
% sigma_calculated(i)= sigma(1,1); %componente xx
sigma_calculated(i)=p(1)*(strain(i)^2) + 2*strain(i)^2*p(2)*((strain(i)^2-1)*(i-p(4))^2*exp(p(3)*(strain(i)^2-1)^2*(1-p(4))^2));
end
error= sum((sigma_calculated-stress).^2) ; %/sum(stress).^2; % Somma dei quadrati delle differenze
%aggiungere normalizzazione rispetto allo stress( guardare script marta calcolo error )
end ga, optimization, nonlinear, curve fitting MATLAB Answers — New Questions
Creating a three-phase UPS in MATLAB
I am having a problem trying to create a Three-phase UPS in MATLAB, I do have an existing file whereby the system works as a single phase. I have then multiplied the system by three and connected it to a load at the output however the output seems to flatline and then rise again, could I get some help on this.
Kind Regards,I am having a problem trying to create a Three-phase UPS in MATLAB, I do have an existing file whereby the system works as a single phase. I have then multiplied the system by three and connected it to a load at the output however the output seems to flatline and then rise again, could I get some help on this.
Kind Regards, I am having a problem trying to create a Three-phase UPS in MATLAB, I do have an existing file whereby the system works as a single phase. I have then multiplied the system by three and connected it to a load at the output however the output seems to flatline and then rise again, could I get some help on this.
Kind Regards, power_conversion_control, ups, three-phase MATLAB Answers — New Questions
geoplot3 for subsurface lines
Dear community,
I fing the geoglobe and geoplot3 functions reallly nice and powerful, yet I have been trying to plot a simple case without succeeding.
I want to plot lines that are located below the surface (underground tunnels, wells, etc.). Is there a workaround to play with the ground layer "transparency" to see those lines that are drawn efectively below, but hidden by the surface?
An extract of the code I’m using:
uif = uifigure;
lat=[43.93365285 43.94086810];
lon=[5.48483510 5.48376465];
alt=[483.591 499.640];
g = geoglobe(uif,’Basemap’,’satellite’,"Terrain","gmted2010");
geoplot3(g,lat,lon,alt,’r’,"LineWidth",2)
campos(g,43.912,5.465,700);
campitch(g,0)
camheading(g,20)
Thanks a lot in advance.Dear community,
I fing the geoglobe and geoplot3 functions reallly nice and powerful, yet I have been trying to plot a simple case without succeeding.
I want to plot lines that are located below the surface (underground tunnels, wells, etc.). Is there a workaround to play with the ground layer "transparency" to see those lines that are drawn efectively below, but hidden by the surface?
An extract of the code I’m using:
uif = uifigure;
lat=[43.93365285 43.94086810];
lon=[5.48483510 5.48376465];
alt=[483.591 499.640];
g = geoglobe(uif,’Basemap’,’satellite’,"Terrain","gmted2010");
geoplot3(g,lat,lon,alt,’r’,"LineWidth",2)
campos(g,43.912,5.465,700);
campitch(g,0)
camheading(g,20)
Thanks a lot in advance. Dear community,
I fing the geoglobe and geoplot3 functions reallly nice and powerful, yet I have been trying to plot a simple case without succeeding.
I want to plot lines that are located below the surface (underground tunnels, wells, etc.). Is there a workaround to play with the ground layer "transparency" to see those lines that are drawn efectively below, but hidden by the surface?
An extract of the code I’m using:
uif = uifigure;
lat=[43.93365285 43.94086810];
lon=[5.48483510 5.48376465];
alt=[483.591 499.640];
g = geoglobe(uif,’Basemap’,’satellite’,"Terrain","gmted2010");
geoplot3(g,lat,lon,alt,’r’,"LineWidth",2)
campos(g,43.912,5.465,700);
campitch(g,0)
camheading(g,20)
Thanks a lot in advance. geoplot3 MATLAB Answers — New Questions
Can I use the same test cases for both a fixed-point and floating-point model in Simulink Test?
I am doing model-in-loop (normal simulation) and software-in-loop testing on my models (codegen). Previously, I have been working with floating-point models and am now moving to work with fixed-point models. I am interested in knowing how Simulink Test supports signal and parameter scaling for fixed-point models in SIL workflows, and whether I need to provide parameter scaling and offsets for floating-point to fixed-point conversion of model inputs and outputs. I am familiar with using A2L files to do parameter scaling and offsets for fixed-point data conversion when running tests at the test bench with SIL workflows with other test tools. The input stimulus and expected outputs for my tests are pulled from an external Excel file.
When Simulink Test is used to manage test cases with an external Excel file to provide the input stimulus and expected outputs, and to manage parameter override, all signals and parameters are also in engineering units. This works OK with MIL testing since model is also in the engineering domain. However, the generated code is in integer world, and the SIL simulation takes integer values for inputs and outputs. What can be done in Simulink Test and/or the Excel file so the same test cases can be re-used for both MIL and SIL? Simulink Test should play the role of the Calibration/Test tool and somehow allow the user to specify the scaling and offset so as to unify both worlds."I am doing model-in-loop (normal simulation) and software-in-loop testing on my models (codegen). Previously, I have been working with floating-point models and am now moving to work with fixed-point models. I am interested in knowing how Simulink Test supports signal and parameter scaling for fixed-point models in SIL workflows, and whether I need to provide parameter scaling and offsets for floating-point to fixed-point conversion of model inputs and outputs. I am familiar with using A2L files to do parameter scaling and offsets for fixed-point data conversion when running tests at the test bench with SIL workflows with other test tools. The input stimulus and expected outputs for my tests are pulled from an external Excel file.
When Simulink Test is used to manage test cases with an external Excel file to provide the input stimulus and expected outputs, and to manage parameter override, all signals and parameters are also in engineering units. This works OK with MIL testing since model is also in the engineering domain. However, the generated code is in integer world, and the SIL simulation takes integer values for inputs and outputs. What can be done in Simulink Test and/or the Excel file so the same test cases can be re-used for both MIL and SIL? Simulink Test should play the role of the Calibration/Test tool and somehow allow the user to specify the scaling and offset so as to unify both worlds." I am doing model-in-loop (normal simulation) and software-in-loop testing on my models (codegen). Previously, I have been working with floating-point models and am now moving to work with fixed-point models. I am interested in knowing how Simulink Test supports signal and parameter scaling for fixed-point models in SIL workflows, and whether I need to provide parameter scaling and offsets for floating-point to fixed-point conversion of model inputs and outputs. I am familiar with using A2L files to do parameter scaling and offsets for fixed-point data conversion when running tests at the test bench with SIL workflows with other test tools. The input stimulus and expected outputs for my tests are pulled from an external Excel file.
When Simulink Test is used to manage test cases with an external Excel file to provide the input stimulus and expected outputs, and to manage parameter override, all signals and parameters are also in engineering units. This works OK with MIL testing since model is also in the engineering domain. However, the generated code is in integer world, and the SIL simulation takes integer values for inputs and outputs. What can be done in Simulink Test and/or the Excel file so the same test cases can be re-used for both MIL and SIL? Simulink Test should play the role of the Calibration/Test tool and somehow allow the user to specify the scaling and offset so as to unify both worlds." sil, mil MATLAB Answers — New Questions
Alias blanks in the cell array as a string.
I am using the ‘importdata’ function to read a text file. It reads the numeric data as a matrix and text data as a cell array; now the first element of cell array is all the headers, I use a ‘strsplit’ function to separate each individual variable name in header. The issue is that there are some blank columns in the text file, so the numeric matrix reads it as a ‘NaN’ but the resulting variables (which I used ‘strsplit’ for) eliminates blanks. Now the result is that size(textdata,2) +size(data,2) is not equal to size(variable,2). I want to read blanks in the header as a variable, alias it as ‘empty’I am using the ‘importdata’ function to read a text file. It reads the numeric data as a matrix and text data as a cell array; now the first element of cell array is all the headers, I use a ‘strsplit’ function to separate each individual variable name in header. The issue is that there are some blank columns in the text file, so the numeric matrix reads it as a ‘NaN’ but the resulting variables (which I used ‘strsplit’ for) eliminates blanks. Now the result is that size(textdata,2) +size(data,2) is not equal to size(variable,2). I want to read blanks in the header as a variable, alias it as ‘empty’ I am using the ‘importdata’ function to read a text file. It reads the numeric data as a matrix and text data as a cell array; now the first element of cell array is all the headers, I use a ‘strsplit’ function to separate each individual variable name in header. The issue is that there are some blank columns in the text file, so the numeric matrix reads it as a ‘NaN’ but the resulting variables (which I used ‘strsplit’ for) eliminates blanks. Now the result is that size(textdata,2) +size(data,2) is not equal to size(variable,2). I want to read blanks in the header as a variable, alias it as ‘empty’ textscan, imporatdata, strsplit MATLAB Answers — New Questions
Multiply a cell with a scalar number
Hello all, i have a problem in multiply my cell in Matlab. I have 1×5218 cell wich i want to multiply it with a scalar number. First, i used code like this,
t = readtable(‘100Hz.csv’);
input = t.x10000(1:5218);
new_input = input.*2;
it return,
Undefined operator ‘.*’ for input arguments of type ‘cell’.
Error in FFT_Matlab (line 3)
new_input = Input.*2;
how i solve this problem ? Thank youHello all, i have a problem in multiply my cell in Matlab. I have 1×5218 cell wich i want to multiply it with a scalar number. First, i used code like this,
t = readtable(‘100Hz.csv’);
input = t.x10000(1:5218);
new_input = input.*2;
it return,
Undefined operator ‘.*’ for input arguments of type ‘cell’.
Error in FFT_Matlab (line 3)
new_input = Input.*2;
how i solve this problem ? Thank you Hello all, i have a problem in multiply my cell in Matlab. I have 1×5218 cell wich i want to multiply it with a scalar number. First, i used code like this,
t = readtable(‘100Hz.csv’);
input = t.x10000(1:5218);
new_input = input.*2;
it return,
Undefined operator ‘.*’ for input arguments of type ‘cell’.
Error in FFT_Matlab (line 3)
new_input = Input.*2;
how i solve this problem ? Thank you csv, cell, tab, matlab MATLAB Answers — New Questions
What encoding is used by the file I/O functions such as ‘fileread’?
I am using the "fileread" function to read a text file. What encoding is used when reading this file?I am using the "fileread" function to read a text file. What encoding is used when reading this file? I am using the "fileread" function to read a text file. What encoding is used when reading this file? file, i/o, fileread, fopen MATLAB Answers — New Questions
How to set different solvers for multiple sub-models in Simulink?
How to set different solvers for multiple sub-models in Simulink (Not Simscape)? Or in other words, how to set different solvers for "top" model and "child" models in Simulink?How to set different solvers for multiple sub-models in Simulink (Not Simscape)? Or in other words, how to set different solvers for "top" model and "child" models in Simulink? How to set different solvers for multiple sub-models in Simulink (Not Simscape)? Or in other words, how to set different solvers for "top" model and "child" models in Simulink? MATLAB Answers — New Questions
Why is a password asked in Git Source Control when there is an SSH key?
I have a Git repository, and when I try to use Source Control integration in MATLAB, it always asks for a password. I have installed the ssh keys, and those work fine in Git for Windows terminal. The keys are placed in the correct location. I have the correct "HOME" environment variable. The output of command "git config –list":
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean — %f
filter.lfs.smudge=git-lfs smudge — %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
credential.helper=manager
user.name=****************
user.email=****************core.symlinks=false
core.repositoryformatversion=0
core.filemode=false
core.logallrefupdates=trueremote.origin.url=http://****************.com/test/matlab.gitremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
How to get rid of the password prompt?I have a Git repository, and when I try to use Source Control integration in MATLAB, it always asks for a password. I have installed the ssh keys, and those work fine in Git for Windows terminal. The keys are placed in the correct location. I have the correct "HOME" environment variable. The output of command "git config –list":
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean — %f
filter.lfs.smudge=git-lfs smudge — %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
credential.helper=manager
user.name=****************
user.email=****************core.symlinks=false
core.repositoryformatversion=0
core.filemode=false
core.logallrefupdates=trueremote.origin.url=http://****************.com/test/matlab.gitremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
How to get rid of the password prompt? I have a Git repository, and when I try to use Source Control integration in MATLAB, it always asks for a password. I have installed the ssh keys, and those work fine in Git for Windows terminal. The keys are placed in the correct location. I have the correct "HOME" environment variable. The output of command "git config –list":
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean — %f
filter.lfs.smudge=git-lfs smudge — %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
credential.helper=manager
user.name=****************
user.email=****************core.symlinks=false
core.repositoryformatversion=0
core.filemode=false
core.logallrefupdates=trueremote.origin.url=http://****************.com/test/matlab.gitremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
How to get rid of the password prompt? git, repository, source, control, integration, ssh, password, http MATLAB Answers — New Questions
Why is my ROS node running slower than expected when deployed?
I am generating a ROS node from a Simulink model and deploying to an embedded computer. My model includes ROS Publisher/Subscriber blocks within an enabled subsystem, so that my algorithm only runs when a message is received. When I set the sample time in Solver Parameters to 200 Hz, and then inherit this sample time in my Subscriber block, I can only achieve performance of 30 Hz upon deployment. Why is this the case and how can I improve performance?I am generating a ROS node from a Simulink model and deploying to an embedded computer. My model includes ROS Publisher/Subscriber blocks within an enabled subsystem, so that my algorithm only runs when a message is received. When I set the sample time in Solver Parameters to 200 Hz, and then inherit this sample time in my Subscriber block, I can only achieve performance of 30 Hz upon deployment. Why is this the case and how can I improve performance? I am generating a ROS node from a Simulink model and deploying to an embedded computer. My model includes ROS Publisher/Subscriber blocks within an enabled subsystem, so that my algorithm only runs when a message is received. When I set the sample time in Solver Parameters to 200 Hz, and then inherit this sample time in my Subscriber block, I can only achieve performance of 30 Hz upon deployment. Why is this the case and how can I improve performance? MATLAB Answers — New Questions
How to deploy deep learning networks for Hardware-in-the-Loop (HIL) simulation with, for example, Speedgoat or dSPACE hardware systems from MATLAB R2018b onward?
I want to generate plain code out of my keras deep learning neuronal network to avoid the dependency of third-party libs. I do this in MATLAB R2021a.
After that, I would like to build an S-Function for the use inside a model in MATLAB R2017b for deployment in HIL, which is set up in MATLAB R2017b. What is the recommended workflow?I want to generate plain code out of my keras deep learning neuronal network to avoid the dependency of third-party libs. I do this in MATLAB R2021a.
After that, I would like to build an S-Function for the use inside a model in MATLAB R2017b for deployment in HIL, which is set up in MATLAB R2017b. What is the recommended workflow? I want to generate plain code out of my keras deep learning neuronal network to avoid the dependency of third-party libs. I do this in MATLAB R2021a.
After that, I would like to build an S-Function for the use inside a model in MATLAB R2017b for deployment in HIL, which is set up in MATLAB R2017b. What is the recommended workflow? MATLAB Answers — New Questions
ismatlab function within pop_loadbv not working
I am trying to load some EEG data into matlab using this code:
ampmatrix = nan(totalN, length(triggerlabels));
SNRdb_matrix = nan(totalN, length(triggerlabels));
for PNo = 1:totalN % loop to iterate through each EEG data file
[EEG, com] = pop_loadbv(‘C:UsersGeorgOneDrive – University of XXXEEG_data’, files(PNo).name);
(with my actual onedrive not XXX)
and I am getting this error message:
Unrecognized function or variable ‘ismatlab’.
Error in pop_loadbv (line 146)
if ismatlab
^^^^^^^^
I am really stuck! I have tried downloading and setting a path to the bva-io package but it is not working. My EEG folder contains three files for each participants (.eeg, .vhdr and .vmrk) and also has a path set to it. Can anyone help me please?I am trying to load some EEG data into matlab using this code:
ampmatrix = nan(totalN, length(triggerlabels));
SNRdb_matrix = nan(totalN, length(triggerlabels));
for PNo = 1:totalN % loop to iterate through each EEG data file
[EEG, com] = pop_loadbv(‘C:UsersGeorgOneDrive – University of XXXEEG_data’, files(PNo).name);
(with my actual onedrive not XXX)
and I am getting this error message:
Unrecognized function or variable ‘ismatlab’.
Error in pop_loadbv (line 146)
if ismatlab
^^^^^^^^
I am really stuck! I have tried downloading and setting a path to the bva-io package but it is not working. My EEG folder contains three files for each participants (.eeg, .vhdr and .vmrk) and also has a path set to it. Can anyone help me please? I am trying to load some EEG data into matlab using this code:
ampmatrix = nan(totalN, length(triggerlabels));
SNRdb_matrix = nan(totalN, length(triggerlabels));
for PNo = 1:totalN % loop to iterate through each EEG data file
[EEG, com] = pop_loadbv(‘C:UsersGeorgOneDrive – University of XXXEEG_data’, files(PNo).name);
(with my actual onedrive not XXX)
and I am getting this error message:
Unrecognized function or variable ‘ismatlab’.
Error in pop_loadbv (line 146)
if ismatlab
^^^^^^^^
I am really stuck! I have tried downloading and setting a path to the bva-io package but it is not working. My EEG folder contains three files for each participants (.eeg, .vhdr and .vmrk) and also has a path set to it. Can anyone help me please? eeg, pop_loadbv MATLAB Answers — New Questions
Tiled layout with a nested graph spanning multiple tiles
I would like to nest/superimpose a plot on another, which is part of a tiledlayout and spans multiple tiles. The following works fine:
figure
tiledlayout(1, 6)
nexttile([1 5])
plot(1:10)
nexttile(6)
plot(11:20)
However, the following does not and it results in two figures:
figure
tiledlayout(1, 6)
nexttile([1 5])
plot(1:10)
axes("position", [0.5 0.5 0.2 0.2])
plot(21:30)
nexttile(6)
plot(11:20)I would like to nest/superimpose a plot on another, which is part of a tiledlayout and spans multiple tiles. The following works fine:
figure
tiledlayout(1, 6)
nexttile([1 5])
plot(1:10)
nexttile(6)
plot(11:20)
However, the following does not and it results in two figures:
figure
tiledlayout(1, 6)
nexttile([1 5])
plot(1:10)
axes("position", [0.5 0.5 0.2 0.2])
plot(21:30)
nexttile(6)
plot(11:20) I would like to nest/superimpose a plot on another, which is part of a tiledlayout and spans multiple tiles. The following works fine:
figure
tiledlayout(1, 6)
nexttile([1 5])
plot(1:10)
nexttile(6)
plot(11:20)
However, the following does not and it results in two figures:
figure
tiledlayout(1, 6)
nexttile([1 5])
plot(1:10)
axes("position", [0.5 0.5 0.2 0.2])
plot(21:30)
nexttile(6)
plot(11:20) plotting, tiledlayout, axes, tile MATLAB Answers — New Questions
Programmatically add toolbox within MATLAB docker container.
A MATLAB script is running in the cloud as a docker container.
Steps that I would like the script to do:
Fetch a .mltbx file from a REST API.
Remove previously installed toolboxes
Install new toolbox .
Run a function from this toolbox.
For step 2 and 3 I am using these functions.
‘matlab.addons.toolbox.installedToolboxes’
‘matlab.addons.toolbox.uninstallToolbox(toolbox)’
‘matlab.addons.toolbox.installToolbox(toolbox)’
This works when I run the script locally but when I package it as a docker container using MATLAB compiler and ran it in the cloud the following error is thrown for the installedToolboxes function.
Unable to resolve the name ‘matlab.addons.toolbox.installedToolboxes’.
‘matlab.addons.toolbox.installedToolboxes’ was excluded from packaging for the MATLAB Runtime environment according to the MATLAB Compiler license.
Have the application owner either resolve the file or function from the code, or use the MATLAB function "isdeployed" to ensure the function is not invoked.
Contact the application owner for more details.
MATLAB:undefinedVarOrClass
I also tried to unzip the .mltbx file and copy the .m files to an existing path that is already present in the searchpath. That works but executing the .m file throws the following error:
Previously accessible file "/home/appuser/.MathWorks/MatlabRuntimeCache/R2024b/modelB0/modelBatch/FlowQ.m" is now inaccessible. │
│
Error in fetchAndInstallToolbox (line 41) │
│
Error in modelBatch (line 40) │
│
MATLAB:fileHasDisappeared
I understand that since R2019a, functions that modify the MATLAB search path are unsupported when using MATLAB Compiler. Both things that I tried modify the MATLAB runtime environment in the docker image, so I guess it is normal that these don’t work.
Is there a way to get around this? Is it possible to dynamically add new classes and functions to a docker container?A MATLAB script is running in the cloud as a docker container.
Steps that I would like the script to do:
Fetch a .mltbx file from a REST API.
Remove previously installed toolboxes
Install new toolbox .
Run a function from this toolbox.
For step 2 and 3 I am using these functions.
‘matlab.addons.toolbox.installedToolboxes’
‘matlab.addons.toolbox.uninstallToolbox(toolbox)’
‘matlab.addons.toolbox.installToolbox(toolbox)’
This works when I run the script locally but when I package it as a docker container using MATLAB compiler and ran it in the cloud the following error is thrown for the installedToolboxes function.
Unable to resolve the name ‘matlab.addons.toolbox.installedToolboxes’.
‘matlab.addons.toolbox.installedToolboxes’ was excluded from packaging for the MATLAB Runtime environment according to the MATLAB Compiler license.
Have the application owner either resolve the file or function from the code, or use the MATLAB function "isdeployed" to ensure the function is not invoked.
Contact the application owner for more details.
MATLAB:undefinedVarOrClass
I also tried to unzip the .mltbx file and copy the .m files to an existing path that is already present in the searchpath. That works but executing the .m file throws the following error:
Previously accessible file "/home/appuser/.MathWorks/MatlabRuntimeCache/R2024b/modelB0/modelBatch/FlowQ.m" is now inaccessible. │
│
Error in fetchAndInstallToolbox (line 41) │
│
Error in modelBatch (line 40) │
│
MATLAB:fileHasDisappeared
I understand that since R2019a, functions that modify the MATLAB search path are unsupported when using MATLAB Compiler. Both things that I tried modify the MATLAB runtime environment in the docker image, so I guess it is normal that these don’t work.
Is there a way to get around this? Is it possible to dynamically add new classes and functions to a docker container? A MATLAB script is running in the cloud as a docker container.
Steps that I would like the script to do:
Fetch a .mltbx file from a REST API.
Remove previously installed toolboxes
Install new toolbox .
Run a function from this toolbox.
For step 2 and 3 I am using these functions.
‘matlab.addons.toolbox.installedToolboxes’
‘matlab.addons.toolbox.uninstallToolbox(toolbox)’
‘matlab.addons.toolbox.installToolbox(toolbox)’
This works when I run the script locally but when I package it as a docker container using MATLAB compiler and ran it in the cloud the following error is thrown for the installedToolboxes function.
Unable to resolve the name ‘matlab.addons.toolbox.installedToolboxes’.
‘matlab.addons.toolbox.installedToolboxes’ was excluded from packaging for the MATLAB Runtime environment according to the MATLAB Compiler license.
Have the application owner either resolve the file or function from the code, or use the MATLAB function "isdeployed" to ensure the function is not invoked.
Contact the application owner for more details.
MATLAB:undefinedVarOrClass
I also tried to unzip the .mltbx file and copy the .m files to an existing path that is already present in the searchpath. That works but executing the .m file throws the following error:
Previously accessible file "/home/appuser/.MathWorks/MatlabRuntimeCache/R2024b/modelB0/modelBatch/FlowQ.m" is now inaccessible. │
│
Error in fetchAndInstallToolbox (line 41) │
│
Error in modelBatch (line 40) │
│
MATLAB:fileHasDisappeared
I understand that since R2019a, functions that modify the MATLAB search path are unsupported when using MATLAB Compiler. Both things that I tried modify the MATLAB runtime environment in the docker image, so I guess it is normal that these don’t work.
Is there a way to get around this? Is it possible to dynamically add new classes and functions to a docker container? matlab compiler, toolbox, addons MATLAB Answers — New Questions