Tag Archives: matlab
Spring bodies of my custom actuator design are not showing in simulink simscape
Hi,
I am trying to model my variable stiffness actuator that I designed with CAD programs. When I imported my design from SolidWorks to simscape multibody via SolidWorks to Multibody tool, the model simscape multibody built is not showing the spring bodies. Every other components are there but not the spring bodies.
This is my first time using Simscape Multibody. I did some research, some of the answers were about the inertial data. But when I check the inertial parameters, I saw they already set by simscape.
I am posting some images, can someone help me please?Hi,
I am trying to model my variable stiffness actuator that I designed with CAD programs. When I imported my design from SolidWorks to simscape multibody via SolidWorks to Multibody tool, the model simscape multibody built is not showing the spring bodies. Every other components are there but not the spring bodies.
This is my first time using Simscape Multibody. I did some research, some of the answers were about the inertial data. But when I check the inertial parameters, I saw they already set by simscape.
I am posting some images, can someone help me please? Hi,
I am trying to model my variable stiffness actuator that I designed with CAD programs. When I imported my design from SolidWorks to simscape multibody via SolidWorks to Multibody tool, the model simscape multibody built is not showing the spring bodies. Every other components are there but not the spring bodies.
This is my first time using Simscape Multibody. I did some research, some of the answers were about the inertial data. But when I check the inertial parameters, I saw they already set by simscape.
I am posting some images, can someone help me please? simscape, simulink, spring MATLAB Answers — New Questions
How can I show where an image was clicked from a scatter3 plot?
I created a small app using appDesigner:
It allows loading an RGB image and displaying a CIE Lab scatter plot in 3D. I attached a copy of the app.
My question is, once I clicked a point in the scatter plot, how would I be able to show the corresponding pixel on the 2D image?
I guess I have to respond to the click event of the scatter?
Any help is appreciated.
The slider at the bottom only serves to change the markersize interactively.
I’m slowly getting the hang of appDesigner. But I’m missing the ability to browse variables of the "script" environment and a few other goodies.
Is there documentation on appDesigner?I created a small app using appDesigner:
It allows loading an RGB image and displaying a CIE Lab scatter plot in 3D. I attached a copy of the app.
My question is, once I clicked a point in the scatter plot, how would I be able to show the corresponding pixel on the 2D image?
I guess I have to respond to the click event of the scatter?
Any help is appreciated.
The slider at the bottom only serves to change the markersize interactively.
I’m slowly getting the hang of appDesigner. But I’m missing the ability to browse variables of the "script" environment and a few other goodies.
Is there documentation on appDesigner? I created a small app using appDesigner:
It allows loading an RGB image and displaying a CIE Lab scatter plot in 3D. I attached a copy of the app.
My question is, once I clicked a point in the scatter plot, how would I be able to show the corresponding pixel on the 2D image?
I guess I have to respond to the click event of the scatter?
Any help is appreciated.
The slider at the bottom only serves to change the markersize interactively.
I’m slowly getting the hang of appDesigner. But I’m missing the ability to browse variables of the "script" environment and a few other goodies.
Is there documentation on appDesigner? scatter3, click event MATLAB Answers — New Questions
Why does the pressure in the tank increase too much?
Hello everyone,
I’m trying to make this simple system work.
It is composed of a flow rate source (connected with the properties of the gas used in the system), a constant volume chamber and a gate valve.
There is also a controller so that when the tank reaches 10000 Pa, the valve is opened.
The problem is that when I look at the pressure scope to inspect data, I see a very high pressure (in the order of 10 to the 13 Pa).
I don’t understand why it behaves like this.
Thank you very much for your help.Hello everyone,
I’m trying to make this simple system work.
It is composed of a flow rate source (connected with the properties of the gas used in the system), a constant volume chamber and a gate valve.
There is also a controller so that when the tank reaches 10000 Pa, the valve is opened.
The problem is that when I look at the pressure scope to inspect data, I see a very high pressure (in the order of 10 to the 13 Pa).
I don’t understand why it behaves like this.
Thank you very much for your help. Hello everyone,
I’m trying to make this simple system work.
It is composed of a flow rate source (connected with the properties of the gas used in the system), a constant volume chamber and a gate valve.
There is also a controller so that when the tank reaches 10000 Pa, the valve is opened.
The problem is that when I look at the pressure scope to inspect data, I see a very high pressure (in the order of 10 to the 13 Pa).
I don’t understand why it behaves like this.
Thank you very much for your help. gas systems, simscape fluids MATLAB Answers — New Questions
Loss is still larger than 30?
Loss is still larger than 30?
Loss = zeros(27, 12); % Adjust the size according to the number of pairs
for ii = 1:27
colIndex = 1; % Initialize column index for Loss matrix
for i = 1:2:24
% Calculate initial loss
Loss(ii, colIndex) = (a(ii, i) – a(ii, i+1)) * 100 / a(ii, i);
% Check condition and adjust if necessary
if Loss(ii, colIndex) < 0 && a(ii, i) < a(ii, i+1)
a(ii, i) = a(ii, i+1) + 0.00004;
elseif Loss(ii, colIndex) > 30
a(ii, i+1) = a(ii, i) – 0.00004;
end
% Recalculate loss after adjustment
Loss(ii, colIndex) = (a(ii, i) – a(ii, i+1)) * 100 / a(ii, i);
colIndex = colIndex + 1; % Increment column index for Loss matrix
end
end
% Display the updated matrix ‘a’
disp(a);
% Display the Loss matrix
disp(Loss);Loss is still larger than 30?
Loss = zeros(27, 12); % Adjust the size according to the number of pairs
for ii = 1:27
colIndex = 1; % Initialize column index for Loss matrix
for i = 1:2:24
% Calculate initial loss
Loss(ii, colIndex) = (a(ii, i) – a(ii, i+1)) * 100 / a(ii, i);
% Check condition and adjust if necessary
if Loss(ii, colIndex) < 0 && a(ii, i) < a(ii, i+1)
a(ii, i) = a(ii, i+1) + 0.00004;
elseif Loss(ii, colIndex) > 30
a(ii, i+1) = a(ii, i) – 0.00004;
end
% Recalculate loss after adjustment
Loss(ii, colIndex) = (a(ii, i) – a(ii, i+1)) * 100 / a(ii, i);
colIndex = colIndex + 1; % Increment column index for Loss matrix
end
end
% Display the updated matrix ‘a’
disp(a);
% Display the Loss matrix
disp(Loss); Loss is still larger than 30?
Loss = zeros(27, 12); % Adjust the size according to the number of pairs
for ii = 1:27
colIndex = 1; % Initialize column index for Loss matrix
for i = 1:2:24
% Calculate initial loss
Loss(ii, colIndex) = (a(ii, i) – a(ii, i+1)) * 100 / a(ii, i);
% Check condition and adjust if necessary
if Loss(ii, colIndex) < 0 && a(ii, i) < a(ii, i+1)
a(ii, i) = a(ii, i+1) + 0.00004;
elseif Loss(ii, colIndex) > 30
a(ii, i+1) = a(ii, i) – 0.00004;
end
% Recalculate loss after adjustment
Loss(ii, colIndex) = (a(ii, i) – a(ii, i+1)) * 100 / a(ii, i);
colIndex = colIndex + 1; % Increment column index for Loss matrix
end
end
% Display the updated matrix ‘a’
disp(a);
% Display the Loss matrix
disp(Loss); matlab, if MATLAB Answers — New Questions
Making use of figure numbers is discouraged – what are your workarounds?
Quite a common task, I assume: based on a simulation or measurement run I generate a set of figures to display the results.
I find it convenient to group the figure numbers of a single run in a certain number range, say 1XXX or 2XXX. In this way I can compare specific results of different runs by quickly picking the windows of two figures, say 1003 and 2003.
But Matlab obviously discourages the use of figure numbers. As far as I know
figure(n, Name="Foo") or figure(Number=n, Name="Foo") is not supported, you need two lines
loading a .fig-file into a figure with a certain number is not supported
reassigning a figure number is not supported, the number is read-only
duplicating figures is not natively supported (why?), the copyobj workaround comes with too many limitations
Are there any workarounds to go on with figure numbers that I’m not aware of?
When you create a new figure, Matlab knows what figure number n to choose: the smallest positive integer that is not occupied by an existing figure. Can you somehow manipulate that n, except for creating dummy figures ;-)?
Or what is your trick of dealing with this common task? Prepend a number string to the figure name? The figure window name will read something like "Figure 23: 1003 Foo" – ugly.
Or am I missing something? Is there any usability rationale behind discouraging figure numbers, or is it just a long-standing limitation?Quite a common task, I assume: based on a simulation or measurement run I generate a set of figures to display the results.
I find it convenient to group the figure numbers of a single run in a certain number range, say 1XXX or 2XXX. In this way I can compare specific results of different runs by quickly picking the windows of two figures, say 1003 and 2003.
But Matlab obviously discourages the use of figure numbers. As far as I know
figure(n, Name="Foo") or figure(Number=n, Name="Foo") is not supported, you need two lines
loading a .fig-file into a figure with a certain number is not supported
reassigning a figure number is not supported, the number is read-only
duplicating figures is not natively supported (why?), the copyobj workaround comes with too many limitations
Are there any workarounds to go on with figure numbers that I’m not aware of?
When you create a new figure, Matlab knows what figure number n to choose: the smallest positive integer that is not occupied by an existing figure. Can you somehow manipulate that n, except for creating dummy figures ;-)?
Or what is your trick of dealing with this common task? Prepend a number string to the figure name? The figure window name will read something like "Figure 23: 1003 Foo" – ugly.
Or am I missing something? Is there any usability rationale behind discouraging figure numbers, or is it just a long-standing limitation? Quite a common task, I assume: based on a simulation or measurement run I generate a set of figures to display the results.
I find it convenient to group the figure numbers of a single run in a certain number range, say 1XXX or 2XXX. In this way I can compare specific results of different runs by quickly picking the windows of two figures, say 1003 and 2003.
But Matlab obviously discourages the use of figure numbers. As far as I know
figure(n, Name="Foo") or figure(Number=n, Name="Foo") is not supported, you need two lines
loading a .fig-file into a figure with a certain number is not supported
reassigning a figure number is not supported, the number is read-only
duplicating figures is not natively supported (why?), the copyobj workaround comes with too many limitations
Are there any workarounds to go on with figure numbers that I’m not aware of?
When you create a new figure, Matlab knows what figure number n to choose: the smallest positive integer that is not occupied by an existing figure. Can you somehow manipulate that n, except for creating dummy figures ;-)?
Or what is your trick of dealing with this common task? Prepend a number string to the figure name? The figure window name will read something like "Figure 23: 1003 Foo" – ugly.
Or am I missing something? Is there any usability rationale behind discouraging figure numbers, or is it just a long-standing limitation? figure, figure number, figure handle, plotting MATLAB Answers — New Questions
Interpolate differently along different directions
I have a field (V) which is defined on a meshgrid X,Y,Z,V and a set of point on which I want the interpolated field, but I want it to be interpolated along x whith the nearest method (because of some conservation properties of the fields) and along z and y with the linear method is it possible? Can you provide a simple example. Thank you in advanceI have a field (V) which is defined on a meshgrid X,Y,Z,V and a set of point on which I want the interpolated field, but I want it to be interpolated along x whith the nearest method (because of some conservation properties of the fields) and along z and y with the linear method is it possible? Can you provide a simple example. Thank you in advance I have a field (V) which is defined on a meshgrid X,Y,Z,V and a set of point on which I want the interpolated field, but I want it to be interpolated along x whith the nearest method (because of some conservation properties of the fields) and along z and y with the linear method is it possible? Can you provide a simple example. Thank you in advance interpolation MATLAB Answers — New Questions
readmatrix returning last column as NaN
Hello Reader!
I am practicing with figures and am practicing with custom cursors.
To save having a very large matrix in the code instead I have a .txt file with the matrix.
customcursor = readmatrix(‘smileyfacematrix.txt’) ;
As you can see in the image the last column of customcursor is entirely NaN.
This is what the text file looks like.
I can not understand why the last column MATLAB converts entirely to NaN and how I can stop this from happening.Hello Reader!
I am practicing with figures and am practicing with custom cursors.
To save having a very large matrix in the code instead I have a .txt file with the matrix.
customcursor = readmatrix(‘smileyfacematrix.txt’) ;
As you can see in the image the last column of customcursor is entirely NaN.
This is what the text file looks like.
I can not understand why the last column MATLAB converts entirely to NaN and how I can stop this from happening. Hello Reader!
I am practicing with figures and am practicing with custom cursors.
To save having a very large matrix in the code instead I have a .txt file with the matrix.
customcursor = readmatrix(‘smileyfacematrix.txt’) ;
As you can see in the image the last column of customcursor is entirely NaN.
This is what the text file looks like.
I can not understand why the last column MATLAB converts entirely to NaN and how I can stop this from happening. text file, read matrix, nan MATLAB Answers — New Questions
alpha-lamda Prognostic Accuracy
Hi MATLAB community,
Please, I need help.
I have been trying to create a prognostic code using Hidden Markov Model.
Having gotten my state posterior probabilities, how do I perform the a-lamda perfomance metrics? I mean what becomes the trueRUL and what is the estimatedRUL??
Thanks in advance!Hi MATLAB community,
Please, I need help.
I have been trying to create a prognostic code using Hidden Markov Model.
Having gotten my state posterior probabilities, how do I perform the a-lamda perfomance metrics? I mean what becomes the trueRUL and what is the estimatedRUL??
Thanks in advance! Hi MATLAB community,
Please, I need help.
I have been trying to create a prognostic code using Hidden Markov Model.
Having gotten my state posterior probabilities, how do I perform the a-lamda perfomance metrics? I mean what becomes the trueRUL and what is the estimatedRUL??
Thanks in advance! phm, prognostics MATLAB Answers — New Questions
Plotting error bars on grouped bar
R2023b: I am trying to plot error bars on my grouped bar plot. I was able to generate the error bars, however they are offset from the actual bar. I tried two sets of code:
first code:
figure(1); clf;
hb = bar(y); % get the bar handles
hold on;
for k = 1:size(y,2)
% get x positions per group
xpos = hb(k).XData + hb(k).XOffset;
% draw errorbar
errorbar(xpos, y(:,k), err(:,k), ‘LineStyle’, ‘none’, …
‘Color’, ‘k’, ‘LineWidth’, 1);
end
legend(‘Boat wake’,’Wind wave’);
set(gca,’xticklabel’,{‘September Wind’; ‘March Boat’;’March Wind’; ‘May Boat’;’May Wind’; ‘August Boat’});
second code:
figure(1)
hBar = bar(x,y); % Plot Data, Get Handle
hold on
for k1 = 1:length(hBar) % Loop: Plots Error Bars
hb = get(get(hBar(k1)));
midbar = mean(hb);
errorbar(midbar, y(:,k1), errs(:,k1), ‘.’) % plotting errors
sigbarx(k1,:) = midbar; % Use To Plot Significance Bars
end
The figure I generated:R2023b: I am trying to plot error bars on my grouped bar plot. I was able to generate the error bars, however they are offset from the actual bar. I tried two sets of code:
first code:
figure(1); clf;
hb = bar(y); % get the bar handles
hold on;
for k = 1:size(y,2)
% get x positions per group
xpos = hb(k).XData + hb(k).XOffset;
% draw errorbar
errorbar(xpos, y(:,k), err(:,k), ‘LineStyle’, ‘none’, …
‘Color’, ‘k’, ‘LineWidth’, 1);
end
legend(‘Boat wake’,’Wind wave’);
set(gca,’xticklabel’,{‘September Wind’; ‘March Boat’;’March Wind’; ‘May Boat’;’May Wind’; ‘August Boat’});
second code:
figure(1)
hBar = bar(x,y); % Plot Data, Get Handle
hold on
for k1 = 1:length(hBar) % Loop: Plots Error Bars
hb = get(get(hBar(k1)));
midbar = mean(hb);
errorbar(midbar, y(:,k1), errs(:,k1), ‘.’) % plotting errors
sigbarx(k1,:) = midbar; % Use To Plot Significance Bars
end
The figure I generated: R2023b: I am trying to plot error bars on my grouped bar plot. I was able to generate the error bars, however they are offset from the actual bar. I tried two sets of code:
first code:
figure(1); clf;
hb = bar(y); % get the bar handles
hold on;
for k = 1:size(y,2)
% get x positions per group
xpos = hb(k).XData + hb(k).XOffset;
% draw errorbar
errorbar(xpos, y(:,k), err(:,k), ‘LineStyle’, ‘none’, …
‘Color’, ‘k’, ‘LineWidth’, 1);
end
legend(‘Boat wake’,’Wind wave’);
set(gca,’xticklabel’,{‘September Wind’; ‘March Boat’;’March Wind’; ‘May Boat’;’May Wind’; ‘August Boat’});
second code:
figure(1)
hBar = bar(x,y); % Plot Data, Get Handle
hold on
for k1 = 1:length(hBar) % Loop: Plots Error Bars
hb = get(get(hBar(k1)));
midbar = mean(hb);
errorbar(midbar, y(:,k1), errs(:,k1), ‘.’) % plotting errors
sigbarx(k1,:) = midbar; % Use To Plot Significance Bars
end
The figure I generated: bar plot, error bars, standard error MATLAB Answers — New Questions
Inquiry with Modeling Hydrogen Diffusion Through Palladium Filters in MATLAB
I am currently working on a project involving the simulation of hydrogen diffusion through palladium filters with various geometric shapes. Specifically, I need to determine the permeability of the palladium filter and understand how this permeability changes when the shape, thickness and compositions of the filter is altered.
I am planning to use MATLAB, particularly the PDE Toolbox, to set up and solve the relevant diffusion equations. I wonder is that possible using MATLAB.
Thank you so much !I am currently working on a project involving the simulation of hydrogen diffusion through palladium filters with various geometric shapes. Specifically, I need to determine the permeability of the palladium filter and understand how this permeability changes when the shape, thickness and compositions of the filter is altered.
I am planning to use MATLAB, particularly the PDE Toolbox, to set up and solve the relevant diffusion equations. I wonder is that possible using MATLAB.
Thank you so much ! I am currently working on a project involving the simulation of hydrogen diffusion through palladium filters with various geometric shapes. Specifically, I need to determine the permeability of the palladium filter and understand how this permeability changes when the shape, thickness and compositions of the filter is altered.
I am planning to use MATLAB, particularly the PDE Toolbox, to set up and solve the relevant diffusion equations. I wonder is that possible using MATLAB.
Thank you so much ! pde, matlab MATLAB Answers — New Questions
How to execute a k-step predictor within a real-time Simulink model
Hi,
I’m trying to implement a k-step predictor within a real-time Simulink model. For each time step in the real-time simulation, values will be used as initial conditions in a predictor model (nonlinear Simulink model, quite extensive) and marched forward multiple time steps, and then the final predicted value is returned and carried on within the real-time simulation.
The primary concern is that the predictor model contain integrators, which cannot be run repeatedly within each real-time step. I have looked into For Loop blocks, but then I would have to write my own integrators.
Alternatively, I have looked into placing the predictor in a separate "offline model" running in normal mode, where it is called at every real-time step. The issue I ran into with this is the amount of overhead I have to load in when running the extensive predictor model, and thus it won’t be completed between each real-time step.
I understand that this could be done a lot easier if the predictor model is in the form of matlab script rather than a Simulink model. However, the predictor model is quite complex, and it would be highly prefered to not needing to re-write it into script form.
I have been stuck on trying different workarounds, but without much luck. I would greatly appreciate if anyone can shed some light on directions I can take.
Thanks in advance,
TimHi,
I’m trying to implement a k-step predictor within a real-time Simulink model. For each time step in the real-time simulation, values will be used as initial conditions in a predictor model (nonlinear Simulink model, quite extensive) and marched forward multiple time steps, and then the final predicted value is returned and carried on within the real-time simulation.
The primary concern is that the predictor model contain integrators, which cannot be run repeatedly within each real-time step. I have looked into For Loop blocks, but then I would have to write my own integrators.
Alternatively, I have looked into placing the predictor in a separate "offline model" running in normal mode, where it is called at every real-time step. The issue I ran into with this is the amount of overhead I have to load in when running the extensive predictor model, and thus it won’t be completed between each real-time step.
I understand that this could be done a lot easier if the predictor model is in the form of matlab script rather than a Simulink model. However, the predictor model is quite complex, and it would be highly prefered to not needing to re-write it into script form.
I have been stuck on trying different workarounds, but without much luck. I would greatly appreciate if anyone can shed some light on directions I can take.
Thanks in advance,
Tim Hi,
I’m trying to implement a k-step predictor within a real-time Simulink model. For each time step in the real-time simulation, values will be used as initial conditions in a predictor model (nonlinear Simulink model, quite extensive) and marched forward multiple time steps, and then the final predicted value is returned and carried on within the real-time simulation.
The primary concern is that the predictor model contain integrators, which cannot be run repeatedly within each real-time step. I have looked into For Loop blocks, but then I would have to write my own integrators.
Alternatively, I have looked into placing the predictor in a separate "offline model" running in normal mode, where it is called at every real-time step. The issue I ran into with this is the amount of overhead I have to load in when running the extensive predictor model, and thus it won’t be completed between each real-time step.
I understand that this could be done a lot easier if the predictor model is in the form of matlab script rather than a Simulink model. However, the predictor model is quite complex, and it would be highly prefered to not needing to re-write it into script form.
I have been stuck on trying different workarounds, but without much luck. I would greatly appreciate if anyone can shed some light on directions I can take.
Thanks in advance,
Tim predictor, real-time, integrator MATLAB Answers — New Questions
Can I use custom libraries (.dll/.lib/.so/.a) with Simulink Real-Time?
Are custom Windows libraries (.dll/.lib) or Unix libraries (.so/.a) supported for integration with my real-time model running on Speedgoat hardware when using Simulink Real-Time (SLRT)?Are custom Windows libraries (.dll/.lib) or Unix libraries (.so/.a) supported for integration with my real-time model running on Speedgoat hardware when using Simulink Real-Time (SLRT)? Are custom Windows libraries (.dll/.lib) or Unix libraries (.so/.a) supported for integration with my real-time model running on Speedgoat hardware when using Simulink Real-Time (SLRT)? speedgoat, slrt, dll, lib, so, static, dynamic, linked, library, shared, object, custom, code, precompiled, device, driver MATLAB Answers — New Questions
I want to solve the equation in the picture and use ode45 to solve it, but after running for 5 hours there is still no result, I would like to ask if the program is written wrong or is there any optimization?
%先对方程进行处理,为使用ode45准备
% clc
% clear
% syms r dx2 rm l varphi dvarphi2 dvarphi1 theta1 theta C1 dv1 Lb C2 dvarphi
% syms g Cp dVR omega1 omega2 v V dv2 z %z=(3*pi-8)/(2*pi)避免其中转化为小数
% eqn1=dv2+r*dx2+rm*l*(dvarphi2-varphi*dvarphi1^2)+omega1^2*v+theta1*V+C1*dv1*Lb*z==0;
% eqn2=C2*dvarphi1+dvarphi2+dv2/l+dx2/l+omega2^2*varphi==0;
% eqns=[eqn1 eqn2];
% S=solve(eqns,[dv2,dvarphi2]);
% S.dv2;
% S.dvarphi2;
%变量赋值 其中还没有确定对应的变量的值
clc
clear
m=0.013;
z=(3*pi – 8)/(2*pi);
Lb=0.19;
Ab=0.008*0.0006;
Lp=0.02;
Ap=0.008*0.0002;
l=0.0275;
rho_b=7850;
rho_p=7500;
Eb=109e9;
Ep=106e9;
theta=190e-12;
Cp=12.7e-9;
Ib=1/12*0.008*0.0006^3;
Ip=1/12*0.008*0.0002^3;
R=10000;
Cb=0.0117; %正常摆动时候的阻尼系数
Ch=0.00117; %旋转时候的阻尼系数 论文中没有出现
g=9.81;
dx2=0.2*9.81;
syms y
psi=@(y) 1-cos(pi*y/(2*Lb));
M1=double(rho_b*Ab*int((psi(y))^2,y,[0,Lb])+rho_p*Ap*int((psi(y))^2,y,[0,Lp]));
M2=double(rho_b*Ab*int((psi(y)),y,[0,Lb])+rho_p*Ap*int((psi(y)),y,[0,Lp]));
K=double(Eb*Ib*int(diff(psi(y),y,2)^2,y,[0,Lb])+Ep*Ip*int(diff(psi(y),y,2)^2,y,[0,Lp]));
C1=Cb/(M1+m);
C2=Ch/(m*l^2);
theta1=theta/(M1+m);
rm=m/(M2+m);
r=(M2+m)/(M1+m);
omega1=sqrt(K/M1);
omega2=sqrt(g/l);
%传递参数准备
params = struct(‘z’,z,’Lb’,Lb,’dx2′,dx2,’l’,l,’theta’,theta,’Cp’, Cp, …
‘R’,R,’C1′,C1,’C2′,C2,’theta1′,theta1,’rm’,rm,’r’,r,’omega1′,omega1,’omega2′,omega2);
%采用ode求解
y0=[0 0 0 0 0];
tspan=0:0.001:2;
[t,f]=ode45(@(t,f) odesys(t,f,params),tspan,y0);
%绘图
figure;
plot(t,f(:,1));
title(‘v.time’);
xlabel(‘time’);
ylabel(‘v’);
figure;
plot(t, f(:,3));
title(‘varphi.time’);
xlabel(‘time’);
ylabel(‘varphi’);
figure;
plot(t, f(:,5));
title(‘V.time’);
xlabel(‘time’);
ylabel(‘V’);
function df=odesys(t,f,params)
% 从参数结构体中提取参数
z=params.z;
Lb=params.Lb;
dx2=params.dx2;
l=params.l;
Cp=params.Cp;
R=params.R;
C1=params.C1;
C2=params.C2;
theta=params.theta;
theta1=params.theta1;
rm=params.rm;
r=params.r;
omega1=params.omega1;
omega2=params.omega2;
% 状态变量
v= f(1);
dv1=f(2);
varphi=f(3);
dvarphi1=f(4);
V=f(5);
%微分方程
df=zeros(5,1);
df(1)=dv1; % df(1) 代表 dv/dt
df(3)=dvarphi1; % df(3) 代表 dvarphi/dt
df(2)=(-l*rm*df(3)^2-C2*l*rm*df(3)+v*omega1^2-…
l*rm*varphi*omega2^2+V*theta1+dx2*r-dx2*rm+C1*Lb*df(1)*z)/(rm-1); % df(2) 代表 dv1/dt
df(4)=(l*rm*varphi*df(3)^2+C2*l*df(3)-v*omega1^2+l*varphi*omega2^2+…
dx2-V*theta1-dx2*r-C1*Lb*df(1)*z)/(l*(rm – 1)); % df(4) 代表 dvarphi1/dt
df(5)=(V/R-theta*df(1))/Cp; % df(5) 代表 dV/dt
end%先对方程进行处理,为使用ode45准备
% clc
% clear
% syms r dx2 rm l varphi dvarphi2 dvarphi1 theta1 theta C1 dv1 Lb C2 dvarphi
% syms g Cp dVR omega1 omega2 v V dv2 z %z=(3*pi-8)/(2*pi)避免其中转化为小数
% eqn1=dv2+r*dx2+rm*l*(dvarphi2-varphi*dvarphi1^2)+omega1^2*v+theta1*V+C1*dv1*Lb*z==0;
% eqn2=C2*dvarphi1+dvarphi2+dv2/l+dx2/l+omega2^2*varphi==0;
% eqns=[eqn1 eqn2];
% S=solve(eqns,[dv2,dvarphi2]);
% S.dv2;
% S.dvarphi2;
%变量赋值 其中还没有确定对应的变量的值
clc
clear
m=0.013;
z=(3*pi – 8)/(2*pi);
Lb=0.19;
Ab=0.008*0.0006;
Lp=0.02;
Ap=0.008*0.0002;
l=0.0275;
rho_b=7850;
rho_p=7500;
Eb=109e9;
Ep=106e9;
theta=190e-12;
Cp=12.7e-9;
Ib=1/12*0.008*0.0006^3;
Ip=1/12*0.008*0.0002^3;
R=10000;
Cb=0.0117; %正常摆动时候的阻尼系数
Ch=0.00117; %旋转时候的阻尼系数 论文中没有出现
g=9.81;
dx2=0.2*9.81;
syms y
psi=@(y) 1-cos(pi*y/(2*Lb));
M1=double(rho_b*Ab*int((psi(y))^2,y,[0,Lb])+rho_p*Ap*int((psi(y))^2,y,[0,Lp]));
M2=double(rho_b*Ab*int((psi(y)),y,[0,Lb])+rho_p*Ap*int((psi(y)),y,[0,Lp]));
K=double(Eb*Ib*int(diff(psi(y),y,2)^2,y,[0,Lb])+Ep*Ip*int(diff(psi(y),y,2)^2,y,[0,Lp]));
C1=Cb/(M1+m);
C2=Ch/(m*l^2);
theta1=theta/(M1+m);
rm=m/(M2+m);
r=(M2+m)/(M1+m);
omega1=sqrt(K/M1);
omega2=sqrt(g/l);
%传递参数准备
params = struct(‘z’,z,’Lb’,Lb,’dx2′,dx2,’l’,l,’theta’,theta,’Cp’, Cp, …
‘R’,R,’C1′,C1,’C2′,C2,’theta1′,theta1,’rm’,rm,’r’,r,’omega1′,omega1,’omega2′,omega2);
%采用ode求解
y0=[0 0 0 0 0];
tspan=0:0.001:2;
[t,f]=ode45(@(t,f) odesys(t,f,params),tspan,y0);
%绘图
figure;
plot(t,f(:,1));
title(‘v.time’);
xlabel(‘time’);
ylabel(‘v’);
figure;
plot(t, f(:,3));
title(‘varphi.time’);
xlabel(‘time’);
ylabel(‘varphi’);
figure;
plot(t, f(:,5));
title(‘V.time’);
xlabel(‘time’);
ylabel(‘V’);
function df=odesys(t,f,params)
% 从参数结构体中提取参数
z=params.z;
Lb=params.Lb;
dx2=params.dx2;
l=params.l;
Cp=params.Cp;
R=params.R;
C1=params.C1;
C2=params.C2;
theta=params.theta;
theta1=params.theta1;
rm=params.rm;
r=params.r;
omega1=params.omega1;
omega2=params.omega2;
% 状态变量
v= f(1);
dv1=f(2);
varphi=f(3);
dvarphi1=f(4);
V=f(5);
%微分方程
df=zeros(5,1);
df(1)=dv1; % df(1) 代表 dv/dt
df(3)=dvarphi1; % df(3) 代表 dvarphi/dt
df(2)=(-l*rm*df(3)^2-C2*l*rm*df(3)+v*omega1^2-…
l*rm*varphi*omega2^2+V*theta1+dx2*r-dx2*rm+C1*Lb*df(1)*z)/(rm-1); % df(2) 代表 dv1/dt
df(4)=(l*rm*varphi*df(3)^2+C2*l*df(3)-v*omega1^2+l*varphi*omega2^2+…
dx2-V*theta1-dx2*r-C1*Lb*df(1)*z)/(l*(rm – 1)); % df(4) 代表 dvarphi1/dt
df(5)=(V/R-theta*df(1))/Cp; % df(5) 代表 dV/dt
end %先对方程进行处理,为使用ode45准备
% clc
% clear
% syms r dx2 rm l varphi dvarphi2 dvarphi1 theta1 theta C1 dv1 Lb C2 dvarphi
% syms g Cp dVR omega1 omega2 v V dv2 z %z=(3*pi-8)/(2*pi)避免其中转化为小数
% eqn1=dv2+r*dx2+rm*l*(dvarphi2-varphi*dvarphi1^2)+omega1^2*v+theta1*V+C1*dv1*Lb*z==0;
% eqn2=C2*dvarphi1+dvarphi2+dv2/l+dx2/l+omega2^2*varphi==0;
% eqns=[eqn1 eqn2];
% S=solve(eqns,[dv2,dvarphi2]);
% S.dv2;
% S.dvarphi2;
%变量赋值 其中还没有确定对应的变量的值
clc
clear
m=0.013;
z=(3*pi – 8)/(2*pi);
Lb=0.19;
Ab=0.008*0.0006;
Lp=0.02;
Ap=0.008*0.0002;
l=0.0275;
rho_b=7850;
rho_p=7500;
Eb=109e9;
Ep=106e9;
theta=190e-12;
Cp=12.7e-9;
Ib=1/12*0.008*0.0006^3;
Ip=1/12*0.008*0.0002^3;
R=10000;
Cb=0.0117; %正常摆动时候的阻尼系数
Ch=0.00117; %旋转时候的阻尼系数 论文中没有出现
g=9.81;
dx2=0.2*9.81;
syms y
psi=@(y) 1-cos(pi*y/(2*Lb));
M1=double(rho_b*Ab*int((psi(y))^2,y,[0,Lb])+rho_p*Ap*int((psi(y))^2,y,[0,Lp]));
M2=double(rho_b*Ab*int((psi(y)),y,[0,Lb])+rho_p*Ap*int((psi(y)),y,[0,Lp]));
K=double(Eb*Ib*int(diff(psi(y),y,2)^2,y,[0,Lb])+Ep*Ip*int(diff(psi(y),y,2)^2,y,[0,Lp]));
C1=Cb/(M1+m);
C2=Ch/(m*l^2);
theta1=theta/(M1+m);
rm=m/(M2+m);
r=(M2+m)/(M1+m);
omega1=sqrt(K/M1);
omega2=sqrt(g/l);
%传递参数准备
params = struct(‘z’,z,’Lb’,Lb,’dx2′,dx2,’l’,l,’theta’,theta,’Cp’, Cp, …
‘R’,R,’C1′,C1,’C2′,C2,’theta1′,theta1,’rm’,rm,’r’,r,’omega1′,omega1,’omega2′,omega2);
%采用ode求解
y0=[0 0 0 0 0];
tspan=0:0.001:2;
[t,f]=ode45(@(t,f) odesys(t,f,params),tspan,y0);
%绘图
figure;
plot(t,f(:,1));
title(‘v.time’);
xlabel(‘time’);
ylabel(‘v’);
figure;
plot(t, f(:,3));
title(‘varphi.time’);
xlabel(‘time’);
ylabel(‘varphi’);
figure;
plot(t, f(:,5));
title(‘V.time’);
xlabel(‘time’);
ylabel(‘V’);
function df=odesys(t,f,params)
% 从参数结构体中提取参数
z=params.z;
Lb=params.Lb;
dx2=params.dx2;
l=params.l;
Cp=params.Cp;
R=params.R;
C1=params.C1;
C2=params.C2;
theta=params.theta;
theta1=params.theta1;
rm=params.rm;
r=params.r;
omega1=params.omega1;
omega2=params.omega2;
% 状态变量
v= f(1);
dv1=f(2);
varphi=f(3);
dvarphi1=f(4);
V=f(5);
%微分方程
df=zeros(5,1);
df(1)=dv1; % df(1) 代表 dv/dt
df(3)=dvarphi1; % df(3) 代表 dvarphi/dt
df(2)=(-l*rm*df(3)^2-C2*l*rm*df(3)+v*omega1^2-…
l*rm*varphi*omega2^2+V*theta1+dx2*r-dx2*rm+C1*Lb*df(1)*z)/(rm-1); % df(2) 代表 dv1/dt
df(4)=(l*rm*varphi*df(3)^2+C2*l*df(3)-v*omega1^2+l*varphi*omega2^2+…
dx2-V*theta1-dx2*r-C1*Lb*df(1)*z)/(l*(rm – 1)); % df(4) 代表 dvarphi1/dt
df(5)=(V/R-theta*df(1))/Cp; % df(5) 代表 dV/dt
end transferred MATLAB Answers — New Questions
Use a external function in app designer and display the result in a gauge or Edit Numeric Field using live data as inputs of the function
Hi,
I am trying to use an external function (please, see ‘subcooling.m’ file) that I created which can provide me the subcooling of a P-H diagram in my model. This function needs two inputs: p2 (pressure in sensor 2) and t3 (temperature in sensor 3) .I tested the code in matlab setting predefines values for p2 and t3 and it worked perfect. But now, I want to use such function in the dashboard that I created in app designer using live data for p2 and t3 provided by my simulink model during the simulation, in order to display such value of the subcooling in an Edit Numeric field or a Gauge. The values of p2 and t3 are displayed in another Edit Numeric Field in the dashboard, for that reason I define p2 and t3 in the code as "app.nameofthenumericfield.Value" (please see the image with the part of the app designer code used to calculate and display the subcooling).
However, when I call the function in app deginer and then run the simulink model, it displays me a complete unexpected value and it does not change during the simulation. So I do not know if I am calling incorrectly the function in my app designer code, or there is something wrong with my function (which is working perfect when I test it in matlab) or there is another thing that I am not taking into account.
I will really appreciate your comments!!!
Thanks in advance,Hi,
I am trying to use an external function (please, see ‘subcooling.m’ file) that I created which can provide me the subcooling of a P-H diagram in my model. This function needs two inputs: p2 (pressure in sensor 2) and t3 (temperature in sensor 3) .I tested the code in matlab setting predefines values for p2 and t3 and it worked perfect. But now, I want to use such function in the dashboard that I created in app designer using live data for p2 and t3 provided by my simulink model during the simulation, in order to display such value of the subcooling in an Edit Numeric field or a Gauge. The values of p2 and t3 are displayed in another Edit Numeric Field in the dashboard, for that reason I define p2 and t3 in the code as "app.nameofthenumericfield.Value" (please see the image with the part of the app designer code used to calculate and display the subcooling).
However, when I call the function in app deginer and then run the simulink model, it displays me a complete unexpected value and it does not change during the simulation. So I do not know if I am calling incorrectly the function in my app designer code, or there is something wrong with my function (which is working perfect when I test it in matlab) or there is another thing that I am not taking into account.
I will really appreciate your comments!!!
Thanks in advance, Hi,
I am trying to use an external function (please, see ‘subcooling.m’ file) that I created which can provide me the subcooling of a P-H diagram in my model. This function needs two inputs: p2 (pressure in sensor 2) and t3 (temperature in sensor 3) .I tested the code in matlab setting predefines values for p2 and t3 and it worked perfect. But now, I want to use such function in the dashboard that I created in app designer using live data for p2 and t3 provided by my simulink model during the simulation, in order to display such value of the subcooling in an Edit Numeric field or a Gauge. The values of p2 and t3 are displayed in another Edit Numeric Field in the dashboard, for that reason I define p2 and t3 in the code as "app.nameofthenumericfield.Value" (please see the image with the part of the app designer code used to calculate and display the subcooling).
However, when I call the function in app deginer and then run the simulink model, it displays me a complete unexpected value and it does not change during the simulation. So I do not know if I am calling incorrectly the function in my app designer code, or there is something wrong with my function (which is working perfect when I test it in matlab) or there is another thing that I am not taking into account.
I will really appreciate your comments!!!
Thanks in advance, external function, app designer MATLAB Answers — New Questions
set parameter in the Condenser Evaporator (2P-MA) block in app Designer
Hi,
I want to set a particular parameter (number of two-phase fluid tubes ) of the block ‘Condenser Evaporator (2P-MA)’ from App designer using a discrete knob. I wrote a code, which is similar when I set parameters for other blocks. However, when I run the app designer code and then I set a particular value using the knob, an error message appears in the code: ‘Condenser Evaporator (2P-MA) block (mask) does not have a parameter named ‘Number of two-phase fluid tubes’ (please, see the image).
Do you know why is that happening, considering that the name of the parameter that I want to set is such one? Or such parameter has another name? Does it has to do with the block is masked?
Thanks in advance for your comments…
Regards,
MauricioHi,
I want to set a particular parameter (number of two-phase fluid tubes ) of the block ‘Condenser Evaporator (2P-MA)’ from App designer using a discrete knob. I wrote a code, which is similar when I set parameters for other blocks. However, when I run the app designer code and then I set a particular value using the knob, an error message appears in the code: ‘Condenser Evaporator (2P-MA) block (mask) does not have a parameter named ‘Number of two-phase fluid tubes’ (please, see the image).
Do you know why is that happening, considering that the name of the parameter that I want to set is such one? Or such parameter has another name? Does it has to do with the block is masked?
Thanks in advance for your comments…
Regards,
Mauricio Hi,
I want to set a particular parameter (number of two-phase fluid tubes ) of the block ‘Condenser Evaporator (2P-MA)’ from App designer using a discrete knob. I wrote a code, which is similar when I set parameters for other blocks. However, when I run the app designer code and then I set a particular value using the knob, an error message appears in the code: ‘Condenser Evaporator (2P-MA) block (mask) does not have a parameter named ‘Number of two-phase fluid tubes’ (please, see the image).
Do you know why is that happening, considering that the name of the parameter that I want to set is such one? Or such parameter has another name? Does it has to do with the block is masked?
Thanks in advance for your comments…
Regards,
Mauricio set parameter, condenser evaporator (2p-ma) block, app designer MATLAB Answers — New Questions
Is angular/radial averaging necessary when converting 2d structurefactor into 1d plot?
I successfully calculated the 2D structure factors of the system, which I want to convert into a 1D plot. Since what I want to study is the hyperuniformity of the system, I need to obtain the structure factor behavior at k as small as possible.
When I use the angular averaging method, the results increase at larger small k, which is not conducive to my use of it to analyze hyperuniformity. The results obtained without averaging perform well, but I think this does not represent the actual changes in physical properties, because as k increases, more data are added, and the overall result must become larger.
So I hope someone can answer the following questions for me:
1. Is angle averaging necessary?
2. Are the results obtained without using angle averaging meaningful?
3. If I have to use angular averaging, how do I solve the problem I’m experiencing?
Thank you a lot.I successfully calculated the 2D structure factors of the system, which I want to convert into a 1D plot. Since what I want to study is the hyperuniformity of the system, I need to obtain the structure factor behavior at k as small as possible.
When I use the angular averaging method, the results increase at larger small k, which is not conducive to my use of it to analyze hyperuniformity. The results obtained without averaging perform well, but I think this does not represent the actual changes in physical properties, because as k increases, more data are added, and the overall result must become larger.
So I hope someone can answer the following questions for me:
1. Is angle averaging necessary?
2. Are the results obtained without using angle averaging meaningful?
3. If I have to use angular averaging, how do I solve the problem I’m experiencing?
Thank you a lot. I successfully calculated the 2D structure factors of the system, which I want to convert into a 1D plot. Since what I want to study is the hyperuniformity of the system, I need to obtain the structure factor behavior at k as small as possible.
When I use the angular averaging method, the results increase at larger small k, which is not conducive to my use of it to analyze hyperuniformity. The results obtained without averaging perform well, but I think this does not represent the actual changes in physical properties, because as k increases, more data are added, and the overall result must become larger.
So I hope someone can answer the following questions for me:
1. Is angle averaging necessary?
2. Are the results obtained without using angle averaging meaningful?
3. If I have to use angular averaging, how do I solve the problem I’m experiencing?
Thank you a lot. structures, fft MATLAB Answers — New Questions
How to solve mex function error caused by libstdc++ library version mismatch ?
Hello,
When compiling a mex function, and running it right after, I get an error saying :
Invalid C++ MEX-file ‘myfun’:
/usr/local/MATLAB/R2023b/interprocess/bin/glnxa64/mex/../../../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.29′ not found (required by …
I saw on this matlab post that the issue is that the libstdc++ version used during compilation is not the one that matlab has on its path during execution. And indeed, the version in "/lib/x86_64-linux-gnu" (i use gcc that links to this lib stdc++ ) and "usr/local/MATLAB/R2023b/sys/os/glnxa64" are not the same.
As explained on the post, launching matlab using LD_PRELOAD to force the use of the right libstdc++ works:
LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6 matlab
But it does not seem very clean. Is there a way to indicate to matlab that it should alwlays at startup load the the version of libstd in /lib/x86_64-linux-gnu ? On the matlab post somebody says that I could simply delete the matlab libstd version, but I don’t know enough about matlab to feel confortable deleting some libraires.
Matt
PS : how I compile the mex function
mex (header_path,lib_path,’-lsome_lib’, …
‘-lgomp’,"CXXFLAGS=$CXXFLAGS ‘-fopenmp’",…
‘COPTIMFLAGS=-O2’,…
"CXXFLAGS=$CXXFLAGS ‘-Wall’",…
"/path/myfun.cpp")Hello,
When compiling a mex function, and running it right after, I get an error saying :
Invalid C++ MEX-file ‘myfun’:
/usr/local/MATLAB/R2023b/interprocess/bin/glnxa64/mex/../../../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.29′ not found (required by …
I saw on this matlab post that the issue is that the libstdc++ version used during compilation is not the one that matlab has on its path during execution. And indeed, the version in "/lib/x86_64-linux-gnu" (i use gcc that links to this lib stdc++ ) and "usr/local/MATLAB/R2023b/sys/os/glnxa64" are not the same.
As explained on the post, launching matlab using LD_PRELOAD to force the use of the right libstdc++ works:
LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6 matlab
But it does not seem very clean. Is there a way to indicate to matlab that it should alwlays at startup load the the version of libstd in /lib/x86_64-linux-gnu ? On the matlab post somebody says that I could simply delete the matlab libstd version, but I don’t know enough about matlab to feel confortable deleting some libraires.
Matt
PS : how I compile the mex function
mex (header_path,lib_path,’-lsome_lib’, …
‘-lgomp’,"CXXFLAGS=$CXXFLAGS ‘-fopenmp’",…
‘COPTIMFLAGS=-O2’,…
"CXXFLAGS=$CXXFLAGS ‘-Wall’",…
"/path/myfun.cpp") Hello,
When compiling a mex function, and running it right after, I get an error saying :
Invalid C++ MEX-file ‘myfun’:
/usr/local/MATLAB/R2023b/interprocess/bin/glnxa64/mex/../../../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.29′ not found (required by …
I saw on this matlab post that the issue is that the libstdc++ version used during compilation is not the one that matlab has on its path during execution. And indeed, the version in "/lib/x86_64-linux-gnu" (i use gcc that links to this lib stdc++ ) and "usr/local/MATLAB/R2023b/sys/os/glnxa64" are not the same.
As explained on the post, launching matlab using LD_PRELOAD to force the use of the right libstdc++ works:
LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6 matlab
But it does not seem very clean. Is there a way to indicate to matlab that it should alwlays at startup load the the version of libstd in /lib/x86_64-linux-gnu ? On the matlab post somebody says that I could simply delete the matlab libstd version, but I don’t know enough about matlab to feel confortable deleting some libraires.
Matt
PS : how I compile the mex function
mex (header_path,lib_path,’-lsome_lib’, …
‘-lgomp’,"CXXFLAGS=$CXXFLAGS ‘-fopenmp’",…
‘COPTIMFLAGS=-O2’,…
"CXXFLAGS=$CXXFLAGS ‘-Wall’",…
"/path/myfun.cpp") mex, glibcxx_3, libstd MATLAB Answers — New Questions
Using a class method as timer callback
Hello,
I am trying to use a matlab app designer class method as a timer callback.
Class definition.
classdef S1_Bluetooth_GUI < matlab.apps.AppBase
I have a timer object called ‘t’ as a class property.
properties (Access = private)
t;
end
This is the timer callback method in a gist.
methods (Access = private)
function execAlive(~,~,app)
% Do stuff with ‘app’, mostly accessing class properties….
end
end
This is the method I am using to register the timer callback. This bit of code is in another member callback that handle component events
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: STARTButton
function STARTButtonPushed(app, event)
app.t = timer(‘Period’, 2 , ‘ExecutionMode’, ‘fixedRate’);
app.t.TimerFcn = {@execAlive,app}; % Register timer callback function
end
end
When I execute this, I am getting the error below
Error while evaluating TimerFcn for timer ‘timer-6’
Undefined function ‘execAlive’ for input arguments of type ‘timer’.
Not sure what I am doing wrong here, somehow the timer callback isn`t working. I have tried the same by putting the callback in a separate script file and that works, but when I try to add it as a class method it doesn`t. Any help would be much appreciated!Hello,
I am trying to use a matlab app designer class method as a timer callback.
Class definition.
classdef S1_Bluetooth_GUI < matlab.apps.AppBase
I have a timer object called ‘t’ as a class property.
properties (Access = private)
t;
end
This is the timer callback method in a gist.
methods (Access = private)
function execAlive(~,~,app)
% Do stuff with ‘app’, mostly accessing class properties….
end
end
This is the method I am using to register the timer callback. This bit of code is in another member callback that handle component events
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: STARTButton
function STARTButtonPushed(app, event)
app.t = timer(‘Period’, 2 , ‘ExecutionMode’, ‘fixedRate’);
app.t.TimerFcn = {@execAlive,app}; % Register timer callback function
end
end
When I execute this, I am getting the error below
Error while evaluating TimerFcn for timer ‘timer-6’
Undefined function ‘execAlive’ for input arguments of type ‘timer’.
Not sure what I am doing wrong here, somehow the timer callback isn`t working. I have tried the same by putting the callback in a separate script file and that works, but when I try to add it as a class method it doesn`t. Any help would be much appreciated! Hello,
I am trying to use a matlab app designer class method as a timer callback.
Class definition.
classdef S1_Bluetooth_GUI < matlab.apps.AppBase
I have a timer object called ‘t’ as a class property.
properties (Access = private)
t;
end
This is the timer callback method in a gist.
methods (Access = private)
function execAlive(~,~,app)
% Do stuff with ‘app’, mostly accessing class properties….
end
end
This is the method I am using to register the timer callback. This bit of code is in another member callback that handle component events
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: STARTButton
function STARTButtonPushed(app, event)
app.t = timer(‘Period’, 2 , ‘ExecutionMode’, ‘fixedRate’);
app.t.TimerFcn = {@execAlive,app}; % Register timer callback function
end
end
When I execute this, I am getting the error below
Error while evaluating TimerFcn for timer ‘timer-6’
Undefined function ‘execAlive’ for input arguments of type ‘timer’.
Not sure what I am doing wrong here, somehow the timer callback isn`t working. I have tried the same by putting the callback in a separate script file and that works, but when I try to add it as a class method it doesn`t. Any help would be much appreciated! timer, callback, class method MATLAB Answers — New Questions
Connection between Matlab and Unity3D
I need to integrate GA optimization of matlab with the game engine tool of Unity3D. Now what I need is to generate the solutions using matlab and send it to Unity3D. Unity3D will calculate the objective function and will return the results again to matlab in order generate the next solutions and so on. Is this process possible? If so, could you please support me with any information or documents that can guide my work?I need to integrate GA optimization of matlab with the game engine tool of Unity3D. Now what I need is to generate the solutions using matlab and send it to Unity3D. Unity3D will calculate the objective function and will return the results again to matlab in order generate the next solutions and so on. Is this process possible? If so, could you please support me with any information or documents that can guide my work? I need to integrate GA optimization of matlab with the game engine tool of Unity3D. Now what I need is to generate the solutions using matlab and send it to Unity3D. Unity3D will calculate the objective function and will return the results again to matlab in order generate the next solutions and so on. Is this process possible? If so, could you please support me with any information or documents that can guide my work? optimization, using ga MATLAB Answers — New Questions
Why are there dips in the voltage output for this diesel generator model?
Hello everyone,
I recently tried to model a diesel generator in Matlab-Simulink. I implemented an engine governing system as well as an excitation system following the values from Matlab’s Emergency Diesel Generator model to a create a diesel generator using a Synchronous Machine with a power rating of 16kVA, 400V and 50hz (one of the preset models).
After running the simulation for 24s (each second is supposed to represent an hour) with a powergui block using the discrete solver (with a time step of 2e-5), I obtained these results and I’m not sure why there are periodic dips in the voltage (and current). Can anyone provide me with answers?
Thank you in advance !Hello everyone,
I recently tried to model a diesel generator in Matlab-Simulink. I implemented an engine governing system as well as an excitation system following the values from Matlab’s Emergency Diesel Generator model to a create a diesel generator using a Synchronous Machine with a power rating of 16kVA, 400V and 50hz (one of the preset models).
After running the simulation for 24s (each second is supposed to represent an hour) with a powergui block using the discrete solver (with a time step of 2e-5), I obtained these results and I’m not sure why there are periodic dips in the voltage (and current). Can anyone provide me with answers?
Thank you in advance ! Hello everyone,
I recently tried to model a diesel generator in Matlab-Simulink. I implemented an engine governing system as well as an excitation system following the values from Matlab’s Emergency Diesel Generator model to a create a diesel generator using a Synchronous Machine with a power rating of 16kVA, 400V and 50hz (one of the preset models).
After running the simulation for 24s (each second is supposed to represent an hour) with a powergui block using the discrete solver (with a time step of 2e-5), I obtained these results and I’m not sure why there are periodic dips in the voltage (and current). Can anyone provide me with answers?
Thank you in advance ! simpowersystems, simulink MATLAB Answers — New Questions