Category: Matlab
Category Archives: Matlab
why is NaN not of ‘NaN type’ in Simulink?
Hi everyone,
Please, could anyone explain why the constant block NaN is not of type NaN?
Thank you in advance!
Best regards,
NicolasHi everyone,
Please, could anyone explain why the constant block NaN is not of type NaN?
Thank you in advance!
Best regards,
Nicolas Hi everyone,
Please, could anyone explain why the constant block NaN is not of type NaN?
Thank you in advance!
Best regards,
Nicolas simulink, nan MATLAB Answers — New Questions
How to use operations in for loop problems
For values of 1 to 60, create a for-loop that does the following. If the value is 1 to 20, have
the operation be number2, if the value is 21 to 40, have the operation be number, and if the
value is 41 to 60, have the operation be √number. Store all 60 results in 3 different variables
that start at 1. With the results, create a 3×20 matrix where the first row is the results of the
first operation, the second row being the results of the second operation, and the final row
being the results of the final operationFor values of 1 to 60, create a for-loop that does the following. If the value is 1 to 20, have
the operation be number2, if the value is 21 to 40, have the operation be number, and if the
value is 41 to 60, have the operation be √number. Store all 60 results in 3 different variables
that start at 1. With the results, create a 3×20 matrix where the first row is the results of the
first operation, the second row being the results of the second operation, and the final row
being the results of the final operation For values of 1 to 60, create a for-loop that does the following. If the value is 1 to 20, have
the operation be number2, if the value is 21 to 40, have the operation be number, and if the
value is 41 to 60, have the operation be √number. Store all 60 results in 3 different variables
that start at 1. With the results, create a 3×20 matrix where the first row is the results of the
first operation, the second row being the results of the second operation, and the final row
being the results of the final operation for loop, operations, matrix MATLAB Answers — New Questions
colorbar label along y-axis instead of x-axis
Hello! I would like the colorbar label to appear directly underneath the colorbar (right underneath the "220" in the figure below), horizontal along the x axis. However, when I specify this as follows, it aligns the label along the y axis.
Here is the relevant code:
contourf(lon,lat,tmp2, 25, ‘LineStyle’,’none’);
hold on
colormap(‘turbo’)
set(gca,’fontsize’,14);
ylabel(‘Latitude (circ)’)
xlabel(‘Longitude (circ)’)
h = colorbar;
xlabel(h,'(K)’);
hold off
——
can someone help me change the orientation of that ‘(K)’, and show me how to adjust my code in general so I can make this adjustments in other plots as well? Thanks.Hello! I would like the colorbar label to appear directly underneath the colorbar (right underneath the "220" in the figure below), horizontal along the x axis. However, when I specify this as follows, it aligns the label along the y axis.
Here is the relevant code:
contourf(lon,lat,tmp2, 25, ‘LineStyle’,’none’);
hold on
colormap(‘turbo’)
set(gca,’fontsize’,14);
ylabel(‘Latitude (circ)’)
xlabel(‘Longitude (circ)’)
h = colorbar;
xlabel(h,'(K)’);
hold off
——
can someone help me change the orientation of that ‘(K)’, and show me how to adjust my code in general so I can make this adjustments in other plots as well? Thanks. Hello! I would like the colorbar label to appear directly underneath the colorbar (right underneath the "220" in the figure below), horizontal along the x axis. However, when I specify this as follows, it aligns the label along the y axis.
Here is the relevant code:
contourf(lon,lat,tmp2, 25, ‘LineStyle’,’none’);
hold on
colormap(‘turbo’)
set(gca,’fontsize’,14);
ylabel(‘Latitude (circ)’)
xlabel(‘Longitude (circ)’)
h = colorbar;
xlabel(h,'(K)’);
hold off
——
can someone help me change the orientation of that ‘(K)’, and show me how to adjust my code in general so I can make this adjustments in other plots as well? Thanks. xlabel colorbar, colorbar orientation, colorbar, ylabel colorbar MATLAB Answers — New Questions
MATLAB Web App does not load when it comes to hosting
Hi,
I have truoble loading my web app on my web app homepage.
Other open-source web app example (mortgage calculator) does work well on the web app server,
but the one that I made on web app homepage does not finish loading, after I clicked on homepage.
Does anyone know some possible causes of this infinite loading error?
Thank you for reading.Hi,
I have truoble loading my web app on my web app homepage.
Other open-source web app example (mortgage calculator) does work well on the web app server,
but the one that I made on web app homepage does not finish loading, after I clicked on homepage.
Does anyone know some possible causes of this infinite loading error?
Thank you for reading. Hi,
I have truoble loading my web app on my web app homepage.
Other open-source web app example (mortgage calculator) does work well on the web app server,
but the one that I made on web app homepage does not finish loading, after I clicked on homepage.
Does anyone know some possible causes of this infinite loading error?
Thank you for reading. web app, web app load, web app host MATLAB Answers — New Questions
Can you load a WAVES VST plugin with Audio Toolbox?
I’m trying to load a VST3 plugin from WAVES using loadAudioPlugin() from MATLAB Audio Toolbox but I get the following error (in comments):
loadAudioPlugin(‘/Library/Audio/Plug-Ins/VST3/WaveShell1-VST3 14.17.vst3’)
% Unexpected unknown exception from MEX file..
% Error in hostmexif.newplugininstance
%
% Error in loadAudioPlugin
This seems to be due to Waves using WaveShell as a software gateway to the actual VST plugin — see https://www.waves.com/support/how-to-use-waves-plugins-when-using-custom-vst-folder
Anyone had any success loading a Waves VST3 plugin into MATLAB?I’m trying to load a VST3 plugin from WAVES using loadAudioPlugin() from MATLAB Audio Toolbox but I get the following error (in comments):
loadAudioPlugin(‘/Library/Audio/Plug-Ins/VST3/WaveShell1-VST3 14.17.vst3’)
% Unexpected unknown exception from MEX file..
% Error in hostmexif.newplugininstance
%
% Error in loadAudioPlugin
This seems to be due to Waves using WaveShell as a software gateway to the actual VST plugin — see https://www.waves.com/support/how-to-use-waves-plugins-when-using-custom-vst-folder
Anyone had any success loading a Waves VST3 plugin into MATLAB? I’m trying to load a VST3 plugin from WAVES using loadAudioPlugin() from MATLAB Audio Toolbox but I get the following error (in comments):
loadAudioPlugin(‘/Library/Audio/Plug-Ins/VST3/WaveShell1-VST3 14.17.vst3’)
% Unexpected unknown exception from MEX file..
% Error in hostmexif.newplugininstance
%
% Error in loadAudioPlugin
This seems to be due to Waves using WaveShell as a software gateway to the actual VST plugin — see https://www.waves.com/support/how-to-use-waves-plugins-when-using-custom-vst-folder
Anyone had any success loading a Waves VST3 plugin into MATLAB? waves, audio toolbox, vst plugin MATLAB Answers — New Questions
Find Eigenvalues of ODE45 Solution MATLAB
I have the following non-linear ODE:
I have the following ODE45 solution:
fun = @(t,X)odefun(X,K,C,M,F(t),resSize);
[t_ode,X_answer] = ode45(fun,tspan,X_0);
The input matrices are stiffness K(X), damping C, mass M, and force F. resSize is the total number of masses in the system.
I would like to find the system’s eigenvalues using either the Jacobian matrix, transfer function, or any other viable method.
I have tried using:
[vector,lambda,condition_number] = polyeig(K(X_answer),C,M);
This is tricky since my K matrix is a function handle of X. In other words, K=@(X). X represents a displacement vector of each mass in the system (x_1(t),x_2(t),…x_resSize(t)), where resSize is the total number of masses. My X_answer matrix is a double with dimensions of t_ode by resSize, where each row is the displacement vector of each mass in double form. Is there some way to substitute X_answer into my function handle for K so I can use polyeig()? If not, how would I go about finding my system’s transfer function or Jacobian matrix so that I can find it’s eigenvalues?I have the following non-linear ODE:
I have the following ODE45 solution:
fun = @(t,X)odefun(X,K,C,M,F(t),resSize);
[t_ode,X_answer] = ode45(fun,tspan,X_0);
The input matrices are stiffness K(X), damping C, mass M, and force F. resSize is the total number of masses in the system.
I would like to find the system’s eigenvalues using either the Jacobian matrix, transfer function, or any other viable method.
I have tried using:
[vector,lambda,condition_number] = polyeig(K(X_answer),C,M);
This is tricky since my K matrix is a function handle of X. In other words, K=@(X). X represents a displacement vector of each mass in the system (x_1(t),x_2(t),…x_resSize(t)), where resSize is the total number of masses. My X_answer matrix is a double with dimensions of t_ode by resSize, where each row is the displacement vector of each mass in double form. Is there some way to substitute X_answer into my function handle for K so I can use polyeig()? If not, how would I go about finding my system’s transfer function or Jacobian matrix so that I can find it’s eigenvalues? I have the following non-linear ODE:
I have the following ODE45 solution:
fun = @(t,X)odefun(X,K,C,M,F(t),resSize);
[t_ode,X_answer] = ode45(fun,tspan,X_0);
The input matrices are stiffness K(X), damping C, mass M, and force F. resSize is the total number of masses in the system.
I would like to find the system’s eigenvalues using either the Jacobian matrix, transfer function, or any other viable method.
I have tried using:
[vector,lambda,condition_number] = polyeig(K(X_answer),C,M);
This is tricky since my K matrix is a function handle of X. In other words, K=@(X). X represents a displacement vector of each mass in the system (x_1(t),x_2(t),…x_resSize(t)), where resSize is the total number of masses. My X_answer matrix is a double with dimensions of t_ode by resSize, where each row is the displacement vector of each mass in double form. Is there some way to substitute X_answer into my function handle for K so I can use polyeig()? If not, how would I go about finding my system’s transfer function or Jacobian matrix so that I can find it’s eigenvalues? function, ode45, transfer function, matlab MATLAB Answers — New Questions
ExperienceBufferLength in Reinforcement Learning Toolbox
Hello, everyone,
I found a problem with the ‘ExperienceBufferLength’ property in ‘rlDDPGAgentOptions’ when specifying options for rl agents.
Usually this property is set as 1e6 in the examples of the Help documentation, such as here.
In this example, every episode has 600 (60/0.1) steps. Does the agent start to train when the experience buffer is filled up with the experiences (S,A,R,S’). If so, it would take at least 1667 (1000000/600 ) episodes before the agent starts to improve.
So I want to know how to determine this value.Hello, everyone,
I found a problem with the ‘ExperienceBufferLength’ property in ‘rlDDPGAgentOptions’ when specifying options for rl agents.
Usually this property is set as 1e6 in the examples of the Help documentation, such as here.
In this example, every episode has 600 (60/0.1) steps. Does the agent start to train when the experience buffer is filled up with the experiences (S,A,R,S’). If so, it would take at least 1667 (1000000/600 ) episodes before the agent starts to improve.
So I want to know how to determine this value. Hello, everyone,
I found a problem with the ‘ExperienceBufferLength’ property in ‘rlDDPGAgentOptions’ when specifying options for rl agents.
Usually this property is set as 1e6 in the examples of the Help documentation, such as here.
In this example, every episode has 600 (60/0.1) steps. Does the agent start to train when the experience buffer is filled up with the experiences (S,A,R,S’). If so, it would take at least 1667 (1000000/600 ) episodes before the agent starts to improve.
So I want to know how to determine this value. reinforcement learning, ddpg, experiencebufferlength MATLAB Answers — New Questions
Error using fmincon and integral2: taking integral variables theta and p as an array while performing computation
I am minimizing q for whole range of p and theta; p has limit from 2pi to 20pi and theta from 0 to pi; to find the value of d, r_g,G_g. q is function of theta, p,d, r_g, G_g.
But while computation p and theta are behaving as an array. Because of this I am getting error. I tried using "ArrayValued", true. This is also not working. How to correct this. Here my part of code
[q] = optimizeParameters();% Call optimizeParameters to define the objective function q
options = optimset(‘PlotFcns’, @optimplotfval);% Set optimization options
d0 = [-0.5, 24, 3e6];
lb = [-1, 24, 2e6];
ub = [0, 32, 6e6];
[solution,fval] = fmincon(@(x)integral2(@(theta,p)q(theta,p,x(1),x(2),x(3)),pi/36,pi/6,2*pi,20*pi),d0,[],[],[],[],lb,ub,[],options); % minimize
function q = optimizeParameters()
Vs = 250;
k = @(p)p/Vs;
c = @(theta)Vs./sin(theta);
w5 = 0.001;
n = 3;
dl = -6;
d1 = @(d)dl + 2 * n * d – d;
q = @(theta, p, d, r_g, G_g) calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
end
function answer = calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
% printing the p and thetahere which is giving an array because of this error in further computation
theta
p
% rest of the code
endI am minimizing q for whole range of p and theta; p has limit from 2pi to 20pi and theta from 0 to pi; to find the value of d, r_g,G_g. q is function of theta, p,d, r_g, G_g.
But while computation p and theta are behaving as an array. Because of this I am getting error. I tried using "ArrayValued", true. This is also not working. How to correct this. Here my part of code
[q] = optimizeParameters();% Call optimizeParameters to define the objective function q
options = optimset(‘PlotFcns’, @optimplotfval);% Set optimization options
d0 = [-0.5, 24, 3e6];
lb = [-1, 24, 2e6];
ub = [0, 32, 6e6];
[solution,fval] = fmincon(@(x)integral2(@(theta,p)q(theta,p,x(1),x(2),x(3)),pi/36,pi/6,2*pi,20*pi),d0,[],[],[],[],lb,ub,[],options); % minimize
function q = optimizeParameters()
Vs = 250;
k = @(p)p/Vs;
c = @(theta)Vs./sin(theta);
w5 = 0.001;
n = 3;
dl = -6;
d1 = @(d)dl + 2 * n * d – d;
q = @(theta, p, d, r_g, G_g) calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
end
function answer = calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
% printing the p and thetahere which is giving an array because of this error in further computation
theta
p
% rest of the code
end I am minimizing q for whole range of p and theta; p has limit from 2pi to 20pi and theta from 0 to pi; to find the value of d, r_g,G_g. q is function of theta, p,d, r_g, G_g.
But while computation p and theta are behaving as an array. Because of this I am getting error. I tried using "ArrayValued", true. This is also not working. How to correct this. Here my part of code
[q] = optimizeParameters();% Call optimizeParameters to define the objective function q
options = optimset(‘PlotFcns’, @optimplotfval);% Set optimization options
d0 = [-0.5, 24, 3e6];
lb = [-1, 24, 2e6];
ub = [0, 32, 6e6];
[solution,fval] = fmincon(@(x)integral2(@(theta,p)q(theta,p,x(1),x(2),x(3)),pi/36,pi/6,2*pi,20*pi),d0,[],[],[],[],lb,ub,[],options); % minimize
function q = optimizeParameters()
Vs = 250;
k = @(p)p/Vs;
c = @(theta)Vs./sin(theta);
w5 = 0.001;
n = 3;
dl = -6;
d1 = @(d)dl + 2 * n * d – d;
q = @(theta, p, d, r_g, G_g) calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
end
function answer = calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
% printing the p and thetahere which is giving an array because of this error in further computation
theta
p
% rest of the code
end integral2, fmicon, arrayvalued MATLAB Answers — New Questions
constrainted regularization to solve ill conditioned problems?
I am trying to solve a matrix equation of the form Ax = b (solving for x with known A and b).
prior to trying regularisation I was using lsqlin (https://uk.mathworks.com/help/optim/ug/lsqlin.html) with the constraints lsqlin(C,d,[],[],[],[],lb,ub) where lb and ub are lower and upper bounds for the allowed values of my output vector. Some (but not all) of my vector values in x should not have negative values. My results are ill-conditioned. I was wondering if anyone is aware of any type of regularisation (e.g. Tikhonov) that has lb or ub constraints such that I can make some (but not all) of my values in x non-negative?
For context:
I have tried using Tikhonov regularisation (the example code given here: https://uk.mathworks.com/matlabcentral/fileexchange/130259-arls-automatically-regularized-least-squares?s_tid=prof_contriblnk – the response from 15 Mar 2024). The issue is that this code does not have any constraints.I am trying to solve a matrix equation of the form Ax = b (solving for x with known A and b).
prior to trying regularisation I was using lsqlin (https://uk.mathworks.com/help/optim/ug/lsqlin.html) with the constraints lsqlin(C,d,[],[],[],[],lb,ub) where lb and ub are lower and upper bounds for the allowed values of my output vector. Some (but not all) of my vector values in x should not have negative values. My results are ill-conditioned. I was wondering if anyone is aware of any type of regularisation (e.g. Tikhonov) that has lb or ub constraints such that I can make some (but not all) of my values in x non-negative?
For context:
I have tried using Tikhonov regularisation (the example code given here: https://uk.mathworks.com/matlabcentral/fileexchange/130259-arls-automatically-regularized-least-squares?s_tid=prof_contriblnk – the response from 15 Mar 2024). The issue is that this code does not have any constraints. I am trying to solve a matrix equation of the form Ax = b (solving for x with known A and b).
prior to trying regularisation I was using lsqlin (https://uk.mathworks.com/help/optim/ug/lsqlin.html) with the constraints lsqlin(C,d,[],[],[],[],lb,ub) where lb and ub are lower and upper bounds for the allowed values of my output vector. Some (but not all) of my vector values in x should not have negative values. My results are ill-conditioned. I was wondering if anyone is aware of any type of regularisation (e.g. Tikhonov) that has lb or ub constraints such that I can make some (but not all) of my values in x non-negative?
For context:
I have tried using Tikhonov regularisation (the example code given here: https://uk.mathworks.com/matlabcentral/fileexchange/130259-arls-automatically-regularized-least-squares?s_tid=prof_contriblnk – the response from 15 Mar 2024). The issue is that this code does not have any constraints. tikhonov, regularisation, ill-conditioned, ill conditioned, matrix equation, constraints, constrained equations MATLAB Answers — New Questions
Raspberry Pi 5 Setup – MATLAB Support Package
I just acquired the new Raspberry Pi 5, and wanted to connect to it through MATLAB. I’m using MATLAB 2021b, and followed the steps in setting up the Support package page for Raspberry Pi hardware. However, when I am asked to select a board there is no option for the Raspberry Pi 5 model, which prompts to me to think that’s not yet supported. Is this the case?I just acquired the new Raspberry Pi 5, and wanted to connect to it through MATLAB. I’m using MATLAB 2021b, and followed the steps in setting up the Support package page for Raspberry Pi hardware. However, when I am asked to select a board there is no option for the Raspberry Pi 5 model, which prompts to me to think that’s not yet supported. Is this the case? I just acquired the new Raspberry Pi 5, and wanted to connect to it through MATLAB. I’m using MATLAB 2021b, and followed the steps in setting up the Support package page for Raspberry Pi hardware. However, when I am asked to select a board there is no option for the Raspberry Pi 5 model, which prompts to me to think that’s not yet supported. Is this the case? #pi5, #supportpackage MATLAB Answers — New Questions
Thermal conductivity varying with temperature shows error: Matrix is too large to convert to linear index.
I am solving a steady state thermal model and want to vary thermal conductivity as a function of temperature for materials present in the model.
I have used
kp = @(location,state) 0.3049+0.006197*state.u-(1.153*10^-5)*(state.u).^2+(1.034*10^-8)*(state.u).^3-(3.352*10^-12)*(state.u).^4; % as function for variable thermal conductivity.
thermalProperties(model,"ThermalConductivity",kp,…
"Face", FaceID); % specific faces are assigned variable thermal conductivity
While solving model slover throws following error:
Matrix is too large to convert to linear index.
Error in pde.DiscretizedPDEModel/checkSpatialCoefsForUDependence (line 73)
self.cu = any(isnan(femat.K(:)));
Error in pde.DiscretizedPDEModel (line 36)
obj = obj.checkSpatialCoefsForUDependence(u0,tdummy);
Error in pde.ThermalModel/solve (line 139)
femodel = pde.DiscretizedPDEModel(self,p,e,t,coefstruct,u0,constCoeffsBCs);
Error in thermal_model_vary_pore_OL_limit_2_phase_updated (line 152)
results = solve(model);
The whole code is too long and uses 4-5 function to run 🙁
I have tried reducing the function for variable thermal conductivity to just linear (removing non-linear dependence on themperature) but it shows the same error.
Thanks in advance!I am solving a steady state thermal model and want to vary thermal conductivity as a function of temperature for materials present in the model.
I have used
kp = @(location,state) 0.3049+0.006197*state.u-(1.153*10^-5)*(state.u).^2+(1.034*10^-8)*(state.u).^3-(3.352*10^-12)*(state.u).^4; % as function for variable thermal conductivity.
thermalProperties(model,"ThermalConductivity",kp,…
"Face", FaceID); % specific faces are assigned variable thermal conductivity
While solving model slover throws following error:
Matrix is too large to convert to linear index.
Error in pde.DiscretizedPDEModel/checkSpatialCoefsForUDependence (line 73)
self.cu = any(isnan(femat.K(:)));
Error in pde.DiscretizedPDEModel (line 36)
obj = obj.checkSpatialCoefsForUDependence(u0,tdummy);
Error in pde.ThermalModel/solve (line 139)
femodel = pde.DiscretizedPDEModel(self,p,e,t,coefstruct,u0,constCoeffsBCs);
Error in thermal_model_vary_pore_OL_limit_2_phase_updated (line 152)
results = solve(model);
The whole code is too long and uses 4-5 function to run 🙁
I have tried reducing the function for variable thermal conductivity to just linear (removing non-linear dependence on themperature) but it shows the same error.
Thanks in advance! I am solving a steady state thermal model and want to vary thermal conductivity as a function of temperature for materials present in the model.
I have used
kp = @(location,state) 0.3049+0.006197*state.u-(1.153*10^-5)*(state.u).^2+(1.034*10^-8)*(state.u).^3-(3.352*10^-12)*(state.u).^4; % as function for variable thermal conductivity.
thermalProperties(model,"ThermalConductivity",kp,…
"Face", FaceID); % specific faces are assigned variable thermal conductivity
While solving model slover throws following error:
Matrix is too large to convert to linear index.
Error in pde.DiscretizedPDEModel/checkSpatialCoefsForUDependence (line 73)
self.cu = any(isnan(femat.K(:)));
Error in pde.DiscretizedPDEModel (line 36)
obj = obj.checkSpatialCoefsForUDependence(u0,tdummy);
Error in pde.ThermalModel/solve (line 139)
femodel = pde.DiscretizedPDEModel(self,p,e,t,coefstruct,u0,constCoeffsBCs);
Error in thermal_model_vary_pore_OL_limit_2_phase_updated (line 152)
results = solve(model);
The whole code is too long and uses 4-5 function to run 🙁
I have tried reducing the function for variable thermal conductivity to just linear (removing non-linear dependence on themperature) but it shows the same error.
Thanks in advance! thermal model, variable thermal conductivity, pde, function, large matrices, fem MATLAB Answers — New Questions
How do I create and place a non-uniform heat flux (Gaussian) on a cylinder with a center hole?
I’m trying to add a non-uniform heat flux to my simple model of a cylinder with a center hole. I know I need to create a function that describes the heat flux (Gaussian) but not sure how to do that in the context of my model. I believe the function can be applied as a thermalBC to Face 2 as shown below.
T_initial = 20;
t_end = 100;
model=createpde(‘thermal’,’transient’);
geo = multicylcinder([.3,2],.2,’void’,[1,0]);
modelGeometry = geo;
pdegplot(model,’FaceLabels’,on);
thermalProperties(model,’ThermalConductivity’,4,’MassDensity’,210,’SpecificHeat’,73);
thermalIC(model,T_initial);
% Heat Flux Function
% ——————
% function Qflux = @nonUniformHeatFlux
% ???
% ???
% ???
% end
thermalBC(model,’Face’,1,’Temperature’,20);
thermalBC(model,’Face’,2,’HeatFlux’,@nonUniformHeatFlux)
generateMesh(model)
pdemesh(model)
tlist = 0:10:t_end
modelresults = solve(model, tlist)
endI’m trying to add a non-uniform heat flux to my simple model of a cylinder with a center hole. I know I need to create a function that describes the heat flux (Gaussian) but not sure how to do that in the context of my model. I believe the function can be applied as a thermalBC to Face 2 as shown below.
T_initial = 20;
t_end = 100;
model=createpde(‘thermal’,’transient’);
geo = multicylcinder([.3,2],.2,’void’,[1,0]);
modelGeometry = geo;
pdegplot(model,’FaceLabels’,on);
thermalProperties(model,’ThermalConductivity’,4,’MassDensity’,210,’SpecificHeat’,73);
thermalIC(model,T_initial);
% Heat Flux Function
% ——————
% function Qflux = @nonUniformHeatFlux
% ???
% ???
% ???
% end
thermalBC(model,’Face’,1,’Temperature’,20);
thermalBC(model,’Face’,2,’HeatFlux’,@nonUniformHeatFlux)
generateMesh(model)
pdemesh(model)
tlist = 0:10:t_end
modelresults = solve(model, tlist)
end I’m trying to add a non-uniform heat flux to my simple model of a cylinder with a center hole. I know I need to create a function that describes the heat flux (Gaussian) but not sure how to do that in the context of my model. I believe the function can be applied as a thermalBC to Face 2 as shown below.
T_initial = 20;
t_end = 100;
model=createpde(‘thermal’,’transient’);
geo = multicylcinder([.3,2],.2,’void’,[1,0]);
modelGeometry = geo;
pdegplot(model,’FaceLabels’,on);
thermalProperties(model,’ThermalConductivity’,4,’MassDensity’,210,’SpecificHeat’,73);
thermalIC(model,T_initial);
% Heat Flux Function
% ——————
% function Qflux = @nonUniformHeatFlux
% ???
% ???
% ???
% end
thermalBC(model,’Face’,1,’Temperature’,20);
thermalBC(model,’Face’,2,’HeatFlux’,@nonUniformHeatFlux)
generateMesh(model)
pdemesh(model)
tlist = 0:10:t_end
modelresults = solve(model, tlist)
end thermal analysis, nonuniform-heat flux MATLAB Answers — New Questions
How to use a variable from script in a function that is in another script
Hello, I am coding a 2nd order differential solver and need to call a variable from the main script into a function script as shown below. I have tried using global however I have read that it is not accepted practice. Also note x2 and x3 are stored in another script called solver.m. Thank you!
fx2x3.m:
function dv3dt = fx2x3 (x2,x3)
dv3dt = ((k3)/(m3))*(x2-x3); %numbers substituted immediately to reduce lines
endHello, I am coding a 2nd order differential solver and need to call a variable from the main script into a function script as shown below. I have tried using global however I have read that it is not accepted practice. Also note x2 and x3 are stored in another script called solver.m. Thank you!
fx2x3.m:
function dv3dt = fx2x3 (x2,x3)
dv3dt = ((k3)/(m3))*(x2-x3); %numbers substituted immediately to reduce lines
end Hello, I am coding a 2nd order differential solver and need to call a variable from the main script into a function script as shown below. I have tried using global however I have read that it is not accepted practice. Also note x2 and x3 are stored in another script called solver.m. Thank you!
fx2x3.m:
function dv3dt = fx2x3 (x2,x3)
dv3dt = ((k3)/(m3))*(x2-x3); %numbers substituted immediately to reduce lines
end matlab code MATLAB Answers — New Questions
Squeeze some part of a plot
Hi, I’d like to squeze the above part of my plot so that the part after the break is 40% of the total y-axis and the below part is 60%. Is it possible to do that? Thank you very much.Hi, I’d like to squeze the above part of my plot so that the part after the break is 40% of the total y-axis and the below part is 60%. Is it possible to do that? Thank you very much. Hi, I’d like to squeze the above part of my plot so that the part after the break is 40% of the total y-axis and the below part is 60%. Is it possible to do that? Thank you very much. plotting, unproportianate axis MATLAB Answers — New Questions
uifigure() laggy with multiple axes, figure() does not support scrollable components
I made an interface to display data from multiple measurement channels. It’s using a Grid Layout Manager, so the first column with fixed pixel width contains channel options, and the second column with "1x" width has axes displaying data. It is Y-scrollable so it can display many channels no matter the window size.
But it gets laggy and possibly unusable when displaying just 10 channels. But I actually found that displaying the same amount of channels in a figure() window is not laggy at all.
But figure() does not support Grid Layout Manager, nor scrollable uipanel…
nb_points = 50e3;
nb_linesperaxes = 1;
nb_axes = 15;
fig = figure("Name","figure()");
fig_ax = arrayfun(@(k)axes(fig,"OuterPosition",[0,1-k/nb_axes,1,1/nb_axes]),…
1:nb_axes);
arrayfun(@(ax)plot(ax,linspace(0,1,nb_points),randn(nb_points,nb_linesperaxes)),…
fig_ax,’UniformOutput’,false);
linkaxes(fig_ax,’x’)
zoom(fig_ax(1),’xon’)
pan(fig_ax(2),’xon’)
uifig = uifigure("Name","uifigure()");
uifig_ax = arrayfun(@(k)axes(uifig,"OuterPosition",[0,1-k/nb_axes,1,1/nb_axes]),…
1:nb_axes);
arrayfun(@(ax)plot(ax,linspace(0,1,nb_points),randn(nb_points,nb_linesperaxes)),…
uifig_ax,’UniformOutput’,false);
linkaxes(uifig_ax,’x’)
zoom(uifig_ax(1),’xon’)
pan(uifig_ax(2),’xon’)
The figure() window works wells, whereas the uifigure() window is laggy. Once compiled as app, it’s even unusable on some not-too-old computers.
Is there an alternative to Grid Layout Manager or scrollable Panel for figure() windows ?
Is there any way to prevent uifigure() window being this laggy ?I made an interface to display data from multiple measurement channels. It’s using a Grid Layout Manager, so the first column with fixed pixel width contains channel options, and the second column with "1x" width has axes displaying data. It is Y-scrollable so it can display many channels no matter the window size.
But it gets laggy and possibly unusable when displaying just 10 channels. But I actually found that displaying the same amount of channels in a figure() window is not laggy at all.
But figure() does not support Grid Layout Manager, nor scrollable uipanel…
nb_points = 50e3;
nb_linesperaxes = 1;
nb_axes = 15;
fig = figure("Name","figure()");
fig_ax = arrayfun(@(k)axes(fig,"OuterPosition",[0,1-k/nb_axes,1,1/nb_axes]),…
1:nb_axes);
arrayfun(@(ax)plot(ax,linspace(0,1,nb_points),randn(nb_points,nb_linesperaxes)),…
fig_ax,’UniformOutput’,false);
linkaxes(fig_ax,’x’)
zoom(fig_ax(1),’xon’)
pan(fig_ax(2),’xon’)
uifig = uifigure("Name","uifigure()");
uifig_ax = arrayfun(@(k)axes(uifig,"OuterPosition",[0,1-k/nb_axes,1,1/nb_axes]),…
1:nb_axes);
arrayfun(@(ax)plot(ax,linspace(0,1,nb_points),randn(nb_points,nb_linesperaxes)),…
uifig_ax,’UniformOutput’,false);
linkaxes(uifig_ax,’x’)
zoom(uifig_ax(1),’xon’)
pan(uifig_ax(2),’xon’)
The figure() window works wells, whereas the uifigure() window is laggy. Once compiled as app, it’s even unusable on some not-too-old computers.
Is there an alternative to Grid Layout Manager or scrollable Panel for figure() windows ?
Is there any way to prevent uifigure() window being this laggy ? I made an interface to display data from multiple measurement channels. It’s using a Grid Layout Manager, so the first column with fixed pixel width contains channel options, and the second column with "1x" width has axes displaying data. It is Y-scrollable so it can display many channels no matter the window size.
But it gets laggy and possibly unusable when displaying just 10 channels. But I actually found that displaying the same amount of channels in a figure() window is not laggy at all.
But figure() does not support Grid Layout Manager, nor scrollable uipanel…
nb_points = 50e3;
nb_linesperaxes = 1;
nb_axes = 15;
fig = figure("Name","figure()");
fig_ax = arrayfun(@(k)axes(fig,"OuterPosition",[0,1-k/nb_axes,1,1/nb_axes]),…
1:nb_axes);
arrayfun(@(ax)plot(ax,linspace(0,1,nb_points),randn(nb_points,nb_linesperaxes)),…
fig_ax,’UniformOutput’,false);
linkaxes(fig_ax,’x’)
zoom(fig_ax(1),’xon’)
pan(fig_ax(2),’xon’)
uifig = uifigure("Name","uifigure()");
uifig_ax = arrayfun(@(k)axes(uifig,"OuterPosition",[0,1-k/nb_axes,1,1/nb_axes]),…
1:nb_axes);
arrayfun(@(ax)plot(ax,linspace(0,1,nb_points),randn(nb_points,nb_linesperaxes)),…
uifig_ax,’UniformOutput’,false);
linkaxes(uifig_ax,’x’)
zoom(uifig_ax(1),’xon’)
pan(uifig_ax(2),’xon’)
The figure() window works wells, whereas the uifigure() window is laggy. Once compiled as app, it’s even unusable on some not-too-old computers.
Is there an alternative to Grid Layout Manager or scrollable Panel for figure() windows ?
Is there any way to prevent uifigure() window being this laggy ? figure, uifigure, performance, laggy, scrollable, grid layout manager MATLAB Answers — New Questions
MATLAB Coder: Why am I receiving Invalid MEX-file error when trying to load a TensorFlowLite model with loadTFLiteModel after upgrading to Update 1 of R2024a release?
I’m using MATLAB Coder and I upgrade to Update 1 of R2024a release. When I try to use the loadTFLiteModel API using the Deep Learning Toolbox Interface for TensorFlow Lite support package, I encounter a strange error (Invalid MEX-file).
What does this error message mean?I’m using MATLAB Coder and I upgrade to Update 1 of R2024a release. When I try to use the loadTFLiteModel API using the Deep Learning Toolbox Interface for TensorFlow Lite support package, I encounter a strange error (Invalid MEX-file).
What does this error message mean? I’m using MATLAB Coder and I upgrade to Update 1 of R2024a release. When I try to use the loadTFLiteModel API using the Deep Learning Toolbox Interface for TensorFlow Lite support package, I encounter a strange error (Invalid MEX-file).
What does this error message mean? neural network, deep learning, matlab coder, code generation, tensorflow, tensorflow-lite, coder-tips MATLAB Answers — New Questions
Unable to run Simulink simulation
I used FilterDesigner to create a banpass filter. I have imported it in Simulink and connected to a chirp block and a spectrum analyzer.
I have quantized the filter inputs and outputs. When I try to simulate, I get the following error:
Expected a GP/Channel-In block to be connected to an input pin in [bandpass3_bandpass3], but instead found block ["Input Quantizer"].I used FilterDesigner to create a banpass filter. I have imported it in Simulink and connected to a chirp block and a spectrum analyzer.
I have quantized the filter inputs and outputs. When I try to simulate, I get the following error:
Expected a GP/Channel-In block to be connected to an input pin in [bandpass3_bandpass3], but instead found block ["Input Quantizer"]. I used FilterDesigner to create a banpass filter. I have imported it in Simulink and connected to a chirp block and a spectrum analyzer.
I have quantized the filter inputs and outputs. When I try to simulate, I get the following error:
Expected a GP/Channel-In block to be connected to an input pin in [bandpass3_bandpass3], but instead found block ["Input Quantizer"]. quantization, filter MATLAB Answers — New Questions
which difference scheme is used in pdepe explicit, implicit, three-layer or symmetric?
which difference scheme is used in pdepe explicit, implicit, three-layer or symmetric? I was asked a question during the course work defense , but I can ‘t find the answer anywhere.which difference scheme is used in pdepe explicit, implicit, three-layer or symmetric? I was asked a question during the course work defense , but I can ‘t find the answer anywhere. which difference scheme is used in pdepe explicit, implicit, three-layer or symmetric? I was asked a question during the course work defense , but I can ‘t find the answer anywhere. difference scheme, pdepe MATLAB Answers — New Questions
How to filter rows from excel in matlab
Hi, I am working on a project and I need this small help. I am currently observing the average speed for cars during weekdays and weekends. Now I have an excel sheet and imported all of the data as column vectors, observation number, time, date, day of the week, average speed of a car, that sort of thing. Now here is where I am stuck. I need to classify or lets say filter all the observations as either weekday or weekend refer to the screenshot for how the excel looks like. so how can I classify the observation as a weekday or weekendHi, I am working on a project and I need this small help. I am currently observing the average speed for cars during weekdays and weekends. Now I have an excel sheet and imported all of the data as column vectors, observation number, time, date, day of the week, average speed of a car, that sort of thing. Now here is where I am stuck. I need to classify or lets say filter all the observations as either weekday or weekend refer to the screenshot for how the excel looks like. so how can I classify the observation as a weekday or weekend Hi, I am working on a project and I need this small help. I am currently observing the average speed for cars during weekdays and weekends. Now I have an excel sheet and imported all of the data as column vectors, observation number, time, date, day of the week, average speed of a car, that sort of thing. Now here is where I am stuck. I need to classify or lets say filter all the observations as either weekday or weekend refer to the screenshot for how the excel looks like. so how can I classify the observation as a weekday or weekend excel, importing excel data, statistics MATLAB Answers — New Questions
Interpolation of matrices with data points having changing derivative
Dear all,
I am trying to define a spline for a set of data whose derivative goes to zero after a certain set of time. Then I have to use this spline for interpolation in a for loop using ppval. But the problem is that in reality the derivative of the spline approaches to zero but the defined spline goes on increasing. At the start both values are matching, the actual and the spline but at larger values the deviation is greater.
In actual scenario, at approximately 20 value at the x axis, the y axis value keeps on increasing, but after that the y value remain approximately constant, even if x-axis value goes to infinity.
Thank you for your response in advance.
RegardsDear all,
I am trying to define a spline for a set of data whose derivative goes to zero after a certain set of time. Then I have to use this spline for interpolation in a for loop using ppval. But the problem is that in reality the derivative of the spline approaches to zero but the defined spline goes on increasing. At the start both values are matching, the actual and the spline but at larger values the deviation is greater.
In actual scenario, at approximately 20 value at the x axis, the y axis value keeps on increasing, but after that the y value remain approximately constant, even if x-axis value goes to infinity.
Thank you for your response in advance.
Regards Dear all,
I am trying to define a spline for a set of data whose derivative goes to zero after a certain set of time. Then I have to use this spline for interpolation in a for loop using ppval. But the problem is that in reality the derivative of the spline approaches to zero but the defined spline goes on increasing. At the start both values are matching, the actual and the spline but at larger values the deviation is greater.
In actual scenario, at approximately 20 value at the x axis, the y axis value keeps on increasing, but after that the y value remain approximately constant, even if x-axis value goes to infinity.
Thank you for your response in advance.
Regards interpolation, matlab, spline MATLAB Answers — New Questions