Category: Matlab
Category Archives: Matlab
Surface Area at given hight of an STL file
Hello All,
I have an STL file and I would like to go through it (z-direction) calculating the surface area on the X-Y plane.
I would like to export the data of the layer number and the corrosponding area measured.
My knowlage in matlab is limited so any tips would help.
Thanks!Hello All,
I have an STL file and I would like to go through it (z-direction) calculating the surface area on the X-Y plane.
I would like to export the data of the layer number and the corrosponding area measured.
My knowlage in matlab is limited so any tips would help.
Thanks! Hello All,
I have an STL file and I would like to go through it (z-direction) calculating the surface area on the X-Y plane.
I would like to export the data of the layer number and the corrosponding area measured.
My knowlage in matlab is limited so any tips would help.
Thanks! stl, surface area, 3d object, table, surface, area MATLAB Answers — New Questions
Why do I get “There was an error while extracting product files. Try rerunning the Installer.” when i try to install matlab r2024b ?
Why do I get "There was an error while extracting product files. Try rerunning the Installer." when i try to install matlab r2024b? When i rerun the installer it happens again.
I tried to download the matlab installer again thinking it was some bug, however it continues to happen every time.
My pc is a windows 10, Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz 3.10 GHz, ram 16,0 GB, ssd 240(150 gb free), motherboard asus P8B75-MWhy do I get "There was an error while extracting product files. Try rerunning the Installer." when i try to install matlab r2024b? When i rerun the installer it happens again.
I tried to download the matlab installer again thinking it was some bug, however it continues to happen every time.
My pc is a windows 10, Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz 3.10 GHz, ram 16,0 GB, ssd 240(150 gb free), motherboard asus P8B75-M Why do I get "There was an error while extracting product files. Try rerunning the Installer." when i try to install matlab r2024b? When i rerun the installer it happens again.
I tried to download the matlab installer again thinking it was some bug, however it continues to happen every time.
My pc is a windows 10, Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz 3.10 GHz, ram 16,0 GB, ssd 240(150 gb free), motherboard asus P8B75-M matlab, installation, error MATLAB Answers — New Questions
Working on sagnac-interferometer, HWP(22.5) rotated laser light 45and tilt by mirror to define emergent orthogonal polarized component with frequency component is introduced.
I am working in Sagnac Interferometers. A vertically polarized liight fromaHe–Ne laser is converted into 45 deg linearly polarized light with the help of a half-wave plate (HWP1) oriented at 22.5 deg with respect to the vertical direction and is spatially filtered and collimated after passing through the spatial filter assembly(SF)and lens L.The beam splitter splits the collimated beam with equal intensity into two arms of the interferometer.The beam transmitted by beam splitter passes through atriangular Sagnac interferometer embedded intoa telescope assembly of lenses. The 45 deg polarized beam enters the polarization beam splitter and splits into two counter propagating orthogo nal polarization components in the triangular Sagnac geometry, and the light emits from the beam splitter as angular multi plexed orthogonally polarized components.The mirrors introduce the desired amount of tilt in the emergent orthogonally polarized components Ox and Oy,which can be representedas Ox(r)= exp(iα1r) and Oy(r)= exp(iα2r) ; where α1 andα2 are the frequency coefficients introduced to the orthogonal polarization components due to their off-axis locations in the front focal plane of lens,and r is the transverse spatial coordinate.I am working in Sagnac Interferometers. A vertically polarized liight fromaHe–Ne laser is converted into 45 deg linearly polarized light with the help of a half-wave plate (HWP1) oriented at 22.5 deg with respect to the vertical direction and is spatially filtered and collimated after passing through the spatial filter assembly(SF)and lens L.The beam splitter splits the collimated beam with equal intensity into two arms of the interferometer.The beam transmitted by beam splitter passes through atriangular Sagnac interferometer embedded intoa telescope assembly of lenses. The 45 deg polarized beam enters the polarization beam splitter and splits into two counter propagating orthogo nal polarization components in the triangular Sagnac geometry, and the light emits from the beam splitter as angular multi plexed orthogonally polarized components.The mirrors introduce the desired amount of tilt in the emergent orthogonally polarized components Ox and Oy,which can be representedas Ox(r)= exp(iα1r) and Oy(r)= exp(iα2r) ; where α1 andα2 are the frequency coefficients introduced to the orthogonal polarization components due to their off-axis locations in the front focal plane of lens,and r is the transverse spatial coordinate. I am working in Sagnac Interferometers. A vertically polarized liight fromaHe–Ne laser is converted into 45 deg linearly polarized light with the help of a half-wave plate (HWP1) oriented at 22.5 deg with respect to the vertical direction and is spatially filtered and collimated after passing through the spatial filter assembly(SF)and lens L.The beam splitter splits the collimated beam with equal intensity into two arms of the interferometer.The beam transmitted by beam splitter passes through atriangular Sagnac interferometer embedded intoa telescope assembly of lenses. The 45 deg polarized beam enters the polarization beam splitter and splits into two counter propagating orthogo nal polarization components in the triangular Sagnac geometry, and the light emits from the beam splitter as angular multi plexed orthogonally polarized components.The mirrors introduce the desired amount of tilt in the emergent orthogonally polarized components Ox and Oy,which can be representedas Ox(r)= exp(iα1r) and Oy(r)= exp(iα2r) ; where α1 andα2 are the frequency coefficients introduced to the orthogonal polarization components due to their off-axis locations in the front focal plane of lens,and r is the transverse spatial coordinate. sagnac interferometers, jones matrix MATLAB Answers — New Questions
Translate from English To Arabic
I tried to translate text from English to Arabic using following code:
url = ‘http://ajax.googleapis.com/ajax/services/language/translate’;
page = urlread(url, ‘get’, {‘v’, ‘1.0’,’q’, ‘Hello’, … ‘langpair’, [‘en’ ‘|’ ‘ar’]});
but the result will be
page =
{"responseData": {"translatedText":""}, "responseDetails": null, "responseStatus": 200}
Please help me to solve this problem.I tried to translate text from English to Arabic using following code:
url = ‘http://ajax.googleapis.com/ajax/services/language/translate’;
page = urlread(url, ‘get’, {‘v’, ‘1.0’,’q’, ‘Hello’, … ‘langpair’, [‘en’ ‘|’ ‘ar’]});
but the result will be
page =
{"responseData": {"translatedText":""}, "responseDetails": null, "responseStatus": 200}
Please help me to solve this problem. I tried to translate text from English to Arabic using following code:
url = ‘http://ajax.googleapis.com/ajax/services/language/translate’;
page = urlread(url, ‘get’, {‘v’, ‘1.0’,’q’, ‘Hello’, … ‘langpair’, [‘en’ ‘|’ ‘ar’]});
but the result will be
page =
{"responseData": {"translatedText":""}, "responseDetails": null, "responseStatus": 200}
Please help me to solve this problem. translate arabic, arabic MATLAB Answers — New Questions
Simulink Support Package For Arduino Hardware (24.2.4) issue
I just updated the Simulink Support Package (24.2.4) For Arduino Hardware. When I add a block from it’s library to my model, the picture of the block is empty. Double clicking the block does not show it’s parameter settings. Instead, it shows the following. I never had this problem with previous versions.
This is a typical error message I recieve when I try to execute.
=== Simulation (Elapsed: 2 sec) ===
Error:Invalid setting in ‘untitled/Digital Output’ for parameter ‘System’.
Caused by:
Error evaluating parameter ‘System’ in ‘untitled/Digital Output’
Unable to resolve the name ‘arduinodriver.ArduinoDigitalIO’.I just updated the Simulink Support Package (24.2.4) For Arduino Hardware. When I add a block from it’s library to my model, the picture of the block is empty. Double clicking the block does not show it’s parameter settings. Instead, it shows the following. I never had this problem with previous versions.
This is a typical error message I recieve when I try to execute.
=== Simulation (Elapsed: 2 sec) ===
Error:Invalid setting in ‘untitled/Digital Output’ for parameter ‘System’.
Caused by:
Error evaluating parameter ‘System’ in ‘untitled/Digital Output’
Unable to resolve the name ‘arduinodriver.ArduinoDigitalIO’. I just updated the Simulink Support Package (24.2.4) For Arduino Hardware. When I add a block from it’s library to my model, the picture of the block is empty. Double clicking the block does not show it’s parameter settings. Instead, it shows the following. I never had this problem with previous versions.
This is a typical error message I recieve when I try to execute.
=== Simulation (Elapsed: 2 sec) ===
Error:Invalid setting in ‘untitled/Digital Output’ for parameter ‘System’.
Caused by:
Error evaluating parameter ‘System’ in ‘untitled/Digital Output’
Unable to resolve the name ‘arduinodriver.ArduinoDigitalIO’. arduino, simulink MATLAB Answers — New Questions
Facing problems in nonlinear system
%%%% Problem_01 %%%%
%u_t=u_xx+6u(1-u)%
%u(0,t)=(1+e^(-5t))^(-2)%
%u(1,t)=(1+e^(1-5t))^(-2)%
%u(x,0)=(1+e^x)^(-2)%
clc;
clear all;
format short
L = 1; % Length of the rod
T = 0.05; % Total time
Nx = 7; % Number of spatial steps
Nt = 10; % Number of time steps
alpha = 1; % Thermal diffusivity
dx = L / Nx; % Spatial step size
dt = T / Nt; % Time step size
r = alpha * dt / dx^2
u = sym(‘u’, [Nx+1,Nt+1]);
% Define the spatial grid
x = linspace(0, L, Nx+1);
x
% Set initial condition u(x,0)
u(:, 1) = vpa(0.0001679.*(x.^2-x)+0.00002215.*(1.5.*x.^3-1.5.*x),9);
% Set Dirichlet boundary conditions
u(1, 🙂 = boundary_condition_x0(linspace(0, T, Nt+1)); % u(0,t)
u(end, 🙂 = boundary_condition_xL(linspace(0, T, Nt+1)); % u(1,t)
u;
% Initialize the source term matrix
f = [];
R = [];
for n = 1:Nt
for j = 1:Nx+1
f_expr = (-10*(exp(x(j)-5*(n-0.5)*dt))/(1+exp(x(j)-5*(n-0.5)*dt))^3) -(2*exp(x(j)-5*(n-0.5)*dt)/(1+exp(x(j)-5*(n-0.5)*dt)^3)*((1-2*exp(x(j)-5*(n-0.5)*dt)))/(1+ …
exp(x(j)-5*(n-0.5)*dt)))-0.0003358-0.00019935*x(j) +6*((1/(1+exp(x(j)-5*(n-0.5)*dt))^2)-0.0001679*(x(j).^2-x(j))-0.00002215*((3/2)*(x(j).^3-x(j))))*(1-(1/(1+ …
exp(x(j)-5*(n-0.5)*dt))^2) +0.0001679*(x(j).^2-x(j))+0.00002215*((3/2)*(x(j).^3-x(j)))) + 6*0.5*(u(j,n)+u(j,n+1))*(1-0.5*(u(j,n)+u(j,n+1)));
f{j,n} = f_expr;
end
for j = 2:Nx
eq = (1-6*r)*u(j-1, n+1) + (10 + 12*r)*u(j, n+1) + (1 – 6*r)*u(j+1, n+1) == (1 + 6*r)*u(j-1, n)…
+ (10-12*r)*u(j, n) + (1 +6*r)*u(j+1, n) + dt*(f{j-1,n} +10*f{j,n} + f{j+1,n});
eqs(n,j-1) = eq;
end
% disp("Equations before solving:");
% disp(vpa(eqs(n, :), 6));
vsol = vpasolve(eqs(n,:));
R = struct2cell(vsol);
for j = 2:Nx
u(j,n+1) = min(abs(R{j-1}));
end
end
vpa(u,9);
esol = @(x,t) (1+exp(x-5*t))^(-2);
exact_sol = [];
Compact_sol = [];
Error_Compact = [];
for n = 2:Nt+1
for j = 2:Nx+1
exact_sol(j,n) = esol((j-1)*dx,(n-1)*dt);
Compact_sol(j,n) = u(j,n);
Error_Compact(j,n) = abs(exact_sol(j,n)-Compact_sol(j,n));
end
end
n = 11; % Choose any specific value of n (1 to 10)
j_values = 1:Nx+1;
u_values = u(j_values, n);
exact_val = exact_sol(j_values, n);
Compact_val = Compact_sol(j_values,n);
Compact_error_val = Error_Compact(j_values, n);
Table = table(u_values, exact_val,Compact_val,Compact_error_val, …
‘VariableNames’, {‘E(i,j)’, ‘Exact_Solution’,’Compact_Solution’,’Compact_Error’})
function bc_x0 = boundary_condition_x0(t)% E(0,t)
bc_x0 = zeros(size(t));
end
function bc_xL = boundary_condition_xL(t)% E(1,t)
bc_xL = zeros(size(t));
end%%%% Problem_01 %%%%
%u_t=u_xx+6u(1-u)%
%u(0,t)=(1+e^(-5t))^(-2)%
%u(1,t)=(1+e^(1-5t))^(-2)%
%u(x,0)=(1+e^x)^(-2)%
clc;
clear all;
format short
L = 1; % Length of the rod
T = 0.05; % Total time
Nx = 7; % Number of spatial steps
Nt = 10; % Number of time steps
alpha = 1; % Thermal diffusivity
dx = L / Nx; % Spatial step size
dt = T / Nt; % Time step size
r = alpha * dt / dx^2
u = sym(‘u’, [Nx+1,Nt+1]);
% Define the spatial grid
x = linspace(0, L, Nx+1);
x
% Set initial condition u(x,0)
u(:, 1) = vpa(0.0001679.*(x.^2-x)+0.00002215.*(1.5.*x.^3-1.5.*x),9);
% Set Dirichlet boundary conditions
u(1, 🙂 = boundary_condition_x0(linspace(0, T, Nt+1)); % u(0,t)
u(end, 🙂 = boundary_condition_xL(linspace(0, T, Nt+1)); % u(1,t)
u;
% Initialize the source term matrix
f = [];
R = [];
for n = 1:Nt
for j = 1:Nx+1
f_expr = (-10*(exp(x(j)-5*(n-0.5)*dt))/(1+exp(x(j)-5*(n-0.5)*dt))^3) -(2*exp(x(j)-5*(n-0.5)*dt)/(1+exp(x(j)-5*(n-0.5)*dt)^3)*((1-2*exp(x(j)-5*(n-0.5)*dt)))/(1+ …
exp(x(j)-5*(n-0.5)*dt)))-0.0003358-0.00019935*x(j) +6*((1/(1+exp(x(j)-5*(n-0.5)*dt))^2)-0.0001679*(x(j).^2-x(j))-0.00002215*((3/2)*(x(j).^3-x(j))))*(1-(1/(1+ …
exp(x(j)-5*(n-0.5)*dt))^2) +0.0001679*(x(j).^2-x(j))+0.00002215*((3/2)*(x(j).^3-x(j)))) + 6*0.5*(u(j,n)+u(j,n+1))*(1-0.5*(u(j,n)+u(j,n+1)));
f{j,n} = f_expr;
end
for j = 2:Nx
eq = (1-6*r)*u(j-1, n+1) + (10 + 12*r)*u(j, n+1) + (1 – 6*r)*u(j+1, n+1) == (1 + 6*r)*u(j-1, n)…
+ (10-12*r)*u(j, n) + (1 +6*r)*u(j+1, n) + dt*(f{j-1,n} +10*f{j,n} + f{j+1,n});
eqs(n,j-1) = eq;
end
% disp("Equations before solving:");
% disp(vpa(eqs(n, :), 6));
vsol = vpasolve(eqs(n,:));
R = struct2cell(vsol);
for j = 2:Nx
u(j,n+1) = min(abs(R{j-1}));
end
end
vpa(u,9);
esol = @(x,t) (1+exp(x-5*t))^(-2);
exact_sol = [];
Compact_sol = [];
Error_Compact = [];
for n = 2:Nt+1
for j = 2:Nx+1
exact_sol(j,n) = esol((j-1)*dx,(n-1)*dt);
Compact_sol(j,n) = u(j,n);
Error_Compact(j,n) = abs(exact_sol(j,n)-Compact_sol(j,n));
end
end
n = 11; % Choose any specific value of n (1 to 10)
j_values = 1:Nx+1;
u_values = u(j_values, n);
exact_val = exact_sol(j_values, n);
Compact_val = Compact_sol(j_values,n);
Compact_error_val = Error_Compact(j_values, n);
Table = table(u_values, exact_val,Compact_val,Compact_error_val, …
‘VariableNames’, {‘E(i,j)’, ‘Exact_Solution’,’Compact_Solution’,’Compact_Error’})
function bc_x0 = boundary_condition_x0(t)% E(0,t)
bc_x0 = zeros(size(t));
end
function bc_xL = boundary_condition_xL(t)% E(1,t)
bc_xL = zeros(size(t));
end %%%% Problem_01 %%%%
%u_t=u_xx+6u(1-u)%
%u(0,t)=(1+e^(-5t))^(-2)%
%u(1,t)=(1+e^(1-5t))^(-2)%
%u(x,0)=(1+e^x)^(-2)%
clc;
clear all;
format short
L = 1; % Length of the rod
T = 0.05; % Total time
Nx = 7; % Number of spatial steps
Nt = 10; % Number of time steps
alpha = 1; % Thermal diffusivity
dx = L / Nx; % Spatial step size
dt = T / Nt; % Time step size
r = alpha * dt / dx^2
u = sym(‘u’, [Nx+1,Nt+1]);
% Define the spatial grid
x = linspace(0, L, Nx+1);
x
% Set initial condition u(x,0)
u(:, 1) = vpa(0.0001679.*(x.^2-x)+0.00002215.*(1.5.*x.^3-1.5.*x),9);
% Set Dirichlet boundary conditions
u(1, 🙂 = boundary_condition_x0(linspace(0, T, Nt+1)); % u(0,t)
u(end, 🙂 = boundary_condition_xL(linspace(0, T, Nt+1)); % u(1,t)
u;
% Initialize the source term matrix
f = [];
R = [];
for n = 1:Nt
for j = 1:Nx+1
f_expr = (-10*(exp(x(j)-5*(n-0.5)*dt))/(1+exp(x(j)-5*(n-0.5)*dt))^3) -(2*exp(x(j)-5*(n-0.5)*dt)/(1+exp(x(j)-5*(n-0.5)*dt)^3)*((1-2*exp(x(j)-5*(n-0.5)*dt)))/(1+ …
exp(x(j)-5*(n-0.5)*dt)))-0.0003358-0.00019935*x(j) +6*((1/(1+exp(x(j)-5*(n-0.5)*dt))^2)-0.0001679*(x(j).^2-x(j))-0.00002215*((3/2)*(x(j).^3-x(j))))*(1-(1/(1+ …
exp(x(j)-5*(n-0.5)*dt))^2) +0.0001679*(x(j).^2-x(j))+0.00002215*((3/2)*(x(j).^3-x(j)))) + 6*0.5*(u(j,n)+u(j,n+1))*(1-0.5*(u(j,n)+u(j,n+1)));
f{j,n} = f_expr;
end
for j = 2:Nx
eq = (1-6*r)*u(j-1, n+1) + (10 + 12*r)*u(j, n+1) + (1 – 6*r)*u(j+1, n+1) == (1 + 6*r)*u(j-1, n)…
+ (10-12*r)*u(j, n) + (1 +6*r)*u(j+1, n) + dt*(f{j-1,n} +10*f{j,n} + f{j+1,n});
eqs(n,j-1) = eq;
end
% disp("Equations before solving:");
% disp(vpa(eqs(n, :), 6));
vsol = vpasolve(eqs(n,:));
R = struct2cell(vsol);
for j = 2:Nx
u(j,n+1) = min(abs(R{j-1}));
end
end
vpa(u,9);
esol = @(x,t) (1+exp(x-5*t))^(-2);
exact_sol = [];
Compact_sol = [];
Error_Compact = [];
for n = 2:Nt+1
for j = 2:Nx+1
exact_sol(j,n) = esol((j-1)*dx,(n-1)*dt);
Compact_sol(j,n) = u(j,n);
Error_Compact(j,n) = abs(exact_sol(j,n)-Compact_sol(j,n));
end
end
n = 11; % Choose any specific value of n (1 to 10)
j_values = 1:Nx+1;
u_values = u(j_values, n);
exact_val = exact_sol(j_values, n);
Compact_val = Compact_sol(j_values,n);
Compact_error_val = Error_Compact(j_values, n);
Table = table(u_values, exact_val,Compact_val,Compact_error_val, …
‘VariableNames’, {‘E(i,j)’, ‘Exact_Solution’,’Compact_Solution’,’Compact_Error’})
function bc_x0 = boundary_condition_x0(t)% E(0,t)
bc_x0 = zeros(size(t));
end
function bc_xL = boundary_condition_xL(t)% E(1,t)
bc_xL = zeros(size(t));
end nonlinear, equation system, solve MATLAB Answers — New Questions
bessel funtion drawing problem part two
I am trying to draw the Neumann Bessel Function. I understand why I need to use harmonic function to draw the Y0(x), but why can’t I draw Y1(x) and Y2(x).
%Neumann Bessel Function
x=(0:0.01:15).’;
i=0:50;
hold on
set(gca,’YLim’,[-1,1]); %range
set(gca,’XLim’,[0,15]); %domain
for m=0:2
j=sum((((-1).^i)./(factorial(i).*factorial(i+m))).*(x./2).^(2*i+m),2);
if m ==0
y = bessely(m, x);
else
i_minus=m:50;
j_minus=sum((((-1).^i_minus)./(factorial(i_minus).*factorial(i_minus-m))).*(x./2).^(2*i_minus-m),2);
y=(j.*cos(m*pi)-j_minus)./(sin(m*pi));
end
plot(x,y)
end
legend(‘Y0′,’Y1′,’Y2’)I am trying to draw the Neumann Bessel Function. I understand why I need to use harmonic function to draw the Y0(x), but why can’t I draw Y1(x) and Y2(x).
%Neumann Bessel Function
x=(0:0.01:15).’;
i=0:50;
hold on
set(gca,’YLim’,[-1,1]); %range
set(gca,’XLim’,[0,15]); %domain
for m=0:2
j=sum((((-1).^i)./(factorial(i).*factorial(i+m))).*(x./2).^(2*i+m),2);
if m ==0
y = bessely(m, x);
else
i_minus=m:50;
j_minus=sum((((-1).^i_minus)./(factorial(i_minus).*factorial(i_minus-m))).*(x./2).^(2*i_minus-m),2);
y=(j.*cos(m*pi)-j_minus)./(sin(m*pi));
end
plot(x,y)
end
legend(‘Y0′,’Y1′,’Y2’) I am trying to draw the Neumann Bessel Function. I understand why I need to use harmonic function to draw the Y0(x), but why can’t I draw Y1(x) and Y2(x).
%Neumann Bessel Function
x=(0:0.01:15).’;
i=0:50;
hold on
set(gca,’YLim’,[-1,1]); %range
set(gca,’XLim’,[0,15]); %domain
for m=0:2
j=sum((((-1).^i)./(factorial(i).*factorial(i+m))).*(x./2).^(2*i+m),2);
if m ==0
y = bessely(m, x);
else
i_minus=m:50;
j_minus=sum((((-1).^i_minus)./(factorial(i_minus).*factorial(i_minus-m))).*(x./2).^(2*i_minus-m),2);
y=(j.*cos(m*pi)-j_minus)./(sin(m*pi));
end
plot(x,y)
end
legend(‘Y0′,’Y1′,’Y2’) differential equations, plot MATLAB Answers — New Questions
How to make a table for two different value but depending on third single value?
If i have a function of A= Bx+zC
then i want a table of x and A for each value of z. For diffrent value of z in one file only with diffrent table.
p= 1;B=0.5;C=0.3
for z= [0 1 2 3]
x=0:0.1:p;
A=B.*x+z*C;
pp = fopen(‘A.txt’,’w’);
fprintf(pp,’%6s %6s %12sn’,’z’,’x’,’A’);
fprintf(pp,’%6.2f %6.2f %12.8fn’,A);
fclose(pp);
end
I got out put which is not to my mark .
z x A
0.90 0.95 1.00000000
1.05 1.10 1.15000000
1.20 1.25 1.30000000
1.35 1.40If i have a function of A= Bx+zC
then i want a table of x and A for each value of z. For diffrent value of z in one file only with diffrent table.
p= 1;B=0.5;C=0.3
for z= [0 1 2 3]
x=0:0.1:p;
A=B.*x+z*C;
pp = fopen(‘A.txt’,’w’);
fprintf(pp,’%6s %6s %12sn’,’z’,’x’,’A’);
fprintf(pp,’%6.2f %6.2f %12.8fn’,A);
fclose(pp);
end
I got out put which is not to my mark .
z x A
0.90 0.95 1.00000000
1.05 1.10 1.15000000
1.20 1.25 1.30000000
1.35 1.40 If i have a function of A= Bx+zC
then i want a table of x and A for each value of z. For diffrent value of z in one file only with diffrent table.
p= 1;B=0.5;C=0.3
for z= [0 1 2 3]
x=0:0.1:p;
A=B.*x+z*C;
pp = fopen(‘A.txt’,’w’);
fprintf(pp,’%6s %6s %12sn’,’z’,’x’,’A’);
fprintf(pp,’%6.2f %6.2f %12.8fn’,A);
fclose(pp);
end
I got out put which is not to my mark .
z x A
0.90 0.95 1.00000000
1.05 1.10 1.15000000
1.20 1.25 1.30000000
1.35 1.40 creating fileid MATLAB Answers — New Questions
How can I replicate this plot using the supplied equations?
Post Content Post Content matlab plot MATLAB Answers — New Questions
Problem with Unpack Block
I need help with Simulink UDP Recieve and the Unpack blocks. I am using a C++ code to stream data from two sensors in our lab via UDP into a Simulink UDP block on the same computer. Each frame of my data contains 10 int_32 values. The first int_32 value is either a 0 or a 1 to indicate which of two sensors is the current frame associated with. The rest of the 9 are the payload data from the sensor.
After receiving the frames from the UDP packet, I also use a Display block to monitor the raw byte values. When I put the byte values in the Display block into a vector and call the char() function on the vector, I get the same signal frame that was sent from each sensor. However, the output from the Unpack block is made of some weird numbers. For instance, when I parse the outputs from the Unpack block into two – (1) sensor identity and (2) payload, the identity value switches between 8240 and 8241 instead of 0 and 1. The payload data is also made up of weird numbers not similar to the actual sensor data. A typical frame of raw data from the sensors appears as this: 0 76 -99 9863 -10 8 -1 184 -87 -56. Can anyone help me? NOTE: In the Unpacking block setting, the same problem using Byte alignment of 1 or 4.I need help with Simulink UDP Recieve and the Unpack blocks. I am using a C++ code to stream data from two sensors in our lab via UDP into a Simulink UDP block on the same computer. Each frame of my data contains 10 int_32 values. The first int_32 value is either a 0 or a 1 to indicate which of two sensors is the current frame associated with. The rest of the 9 are the payload data from the sensor.
After receiving the frames from the UDP packet, I also use a Display block to monitor the raw byte values. When I put the byte values in the Display block into a vector and call the char() function on the vector, I get the same signal frame that was sent from each sensor. However, the output from the Unpack block is made of some weird numbers. For instance, when I parse the outputs from the Unpack block into two – (1) sensor identity and (2) payload, the identity value switches between 8240 and 8241 instead of 0 and 1. The payload data is also made up of weird numbers not similar to the actual sensor data. A typical frame of raw data from the sensors appears as this: 0 76 -99 9863 -10 8 -1 184 -87 -56. Can anyone help me? NOTE: In the Unpacking block setting, the same problem using Byte alignment of 1 or 4. I need help with Simulink UDP Recieve and the Unpack blocks. I am using a C++ code to stream data from two sensors in our lab via UDP into a Simulink UDP block on the same computer. Each frame of my data contains 10 int_32 values. The first int_32 value is either a 0 or a 1 to indicate which of two sensors is the current frame associated with. The rest of the 9 are the payload data from the sensor.
After receiving the frames from the UDP packet, I also use a Display block to monitor the raw byte values. When I put the byte values in the Display block into a vector and call the char() function on the vector, I get the same signal frame that was sent from each sensor. However, the output from the Unpack block is made of some weird numbers. For instance, when I parse the outputs from the Unpack block into two – (1) sensor identity and (2) payload, the identity value switches between 8240 and 8241 instead of 0 and 1. The payload data is also made up of weird numbers not similar to the actual sensor data. A typical frame of raw data from the sensors appears as this: 0 76 -99 9863 -10 8 -1 184 -87 -56. Can anyone help me? NOTE: In the Unpacking block setting, the same problem using Byte alignment of 1 or 4. udp recieve/ unpack block MATLAB Answers — New Questions
tfest function does not recognize nearby poles and zeros in a 2dof system
I am using tfestimate and tfest to experimentally derive the frequency response function of a 2 dof system with 1 input and 2 output.
The problem is that tfest seems to cancel or does not recognize a complex pole pair (resonance) near a complex zero pair (antiresonance) around 6 Hz in the tf from input 1 to output 1 and consequently simplifies the frequency response of the system (see image, correct plot in blue vs simplified plot in red):
I tried different types of windowing in tfestimate but the only one that allows me to obtain the correct frequency response after tfest is rectwin without overlap: this works only with mathematical model I/O data, the blue plot shown above, but with the real model data the problem persists. Other windows like hann (which would be more suitable) also leads to a pole-zero simplification after tfest, with mathematical model I/O data too.
Increasing the number of zeros-poles from 2-4 to 6-8 tfest gives me the correct transfer functions, but I absolutely need the model with 2 zeros and 4 poles for a correct dynamic of the system to control by using the identification of its FRF.
To load I/O data see attachment .mat file
The code is the following:
% Upload I/O data
load ‘test_identificazione_chirp_tauGain_0,1.mat’
% Data from real model
th1abs = theta1_rad_MEAS.signals.values;
th2rel = theta2_rad_MEAS.signals.values;
th2abs = th1abs+th2rel;
tauIn = tauInput.signals.values;
nfs = 4096*4; % Number of samples for FFT
Fs = 1000; % Sampling frequency
% Transfer functions estimate from input 1 (tauIn) to outputs 1 and 2 (th1abs and th2abs)
[H_11, f_H_11] = tfestimate(squeeze(tauIn), squeeze(th1abs), rectwin(floor(size(squeeze(tauIn), 1))), 0, nfs*4, Fs);
[H_21, f_H_21] = tfestimate(squeeze(tauIn), squeeze(th2abs), rectwin(floor(size(squeeze(tauIn), 1))), 0, nfs*4, Fs);
% Try also hann window with overlap to get a better curve: hann(floor(size(squeeze(tauIn), 1) / 15)), 3000
% Estimated tf smoothing, by movmean with [x,x] values
H_11 = movmean(H_11,[2,2]);
H_21 = movmean(H_21,[2,2]);
% Estimated tf plot
figure(1)
subplot(1,2,1);
semilogx(f_H_11, mag2db(abs(H_11)), ‘b’, ‘LineWidth’, 0.7);
hold on;
subplot(1,2,2);
semilogx(f_H_21, mag2db(abs(H_21)), ‘b’, ‘LineWidth’, 0.7);
hold on;
% Frequency range to keep only relevant part of tf by tfestimate
fmin = 0.1; % min freq (Hz)
fmax = 15; % max freq (Hz)
idx_11 = (f_H_11 >= fmin) & (f_H_11 <= fmax); % frequency index in the selected range
idx_21 = (f_H_21 >= fmin) & (f_H_21 <= fmax); % frequency index in the selected range
H_11_filtered = H_11(idx_11);
f_11_filtered = f_H_11(idx_11); % corresponding frequencies
H_21_filtered = H_21(idx_21);
f_21_filtered = f_H_21(idx_21); % corresponding frequencies
% rad/s conversion to use in `idfrd`
f_11_rad = f_11_filtered * 2 * pi;
f_21_rad = f_21_filtered * 2 * pi;
% Filtered tf plot
subplot(1,2,1);
semilogx(f_11_filtered, mag2db(abs(H_11_filtered)), ‘r’, ‘LineWidth’, 0.7);
subplot(1,2,2);
semilogx(f_21_filtered, mag2db(abs(H_21_filtered)), ‘r’, ‘LineWidth’, 0.7);
% Creating an identified model based on frequency data
H_11_idfrd = idfrd(H_11_filtered, f_11_rad, ‘Ts’, 0); % continuous time
H_21_idfrd = idfrd(H_21_filtered, f_21_rad, ‘Ts’, 0); % continuous time
% tf estimation in "tf" variable type
np = 4; % system pole number
nz = 2; % system zero number
sys_est_11 = tfest(H_11_idfrd, np, nz);
sys_est_21 = tfest(H_21_idfrd, np, nz);
sys_est = [sys_est_11; sys_est_21]; % [2×1] dimension
% Estimated FRF plot
figure(2)
P = bodeoptions;
P.FreqUnits = ‘Hz’; % Frequency axys in Hz
bodeplot(sys_est, P);
grid on;
hold on;
% Print estimated tf in the Command Window
sys_est
Any help? Thank you in advance!I am using tfestimate and tfest to experimentally derive the frequency response function of a 2 dof system with 1 input and 2 output.
The problem is that tfest seems to cancel or does not recognize a complex pole pair (resonance) near a complex zero pair (antiresonance) around 6 Hz in the tf from input 1 to output 1 and consequently simplifies the frequency response of the system (see image, correct plot in blue vs simplified plot in red):
I tried different types of windowing in tfestimate but the only one that allows me to obtain the correct frequency response after tfest is rectwin without overlap: this works only with mathematical model I/O data, the blue plot shown above, but with the real model data the problem persists. Other windows like hann (which would be more suitable) also leads to a pole-zero simplification after tfest, with mathematical model I/O data too.
Increasing the number of zeros-poles from 2-4 to 6-8 tfest gives me the correct transfer functions, but I absolutely need the model with 2 zeros and 4 poles for a correct dynamic of the system to control by using the identification of its FRF.
To load I/O data see attachment .mat file
The code is the following:
% Upload I/O data
load ‘test_identificazione_chirp_tauGain_0,1.mat’
% Data from real model
th1abs = theta1_rad_MEAS.signals.values;
th2rel = theta2_rad_MEAS.signals.values;
th2abs = th1abs+th2rel;
tauIn = tauInput.signals.values;
nfs = 4096*4; % Number of samples for FFT
Fs = 1000; % Sampling frequency
% Transfer functions estimate from input 1 (tauIn) to outputs 1 and 2 (th1abs and th2abs)
[H_11, f_H_11] = tfestimate(squeeze(tauIn), squeeze(th1abs), rectwin(floor(size(squeeze(tauIn), 1))), 0, nfs*4, Fs);
[H_21, f_H_21] = tfestimate(squeeze(tauIn), squeeze(th2abs), rectwin(floor(size(squeeze(tauIn), 1))), 0, nfs*4, Fs);
% Try also hann window with overlap to get a better curve: hann(floor(size(squeeze(tauIn), 1) / 15)), 3000
% Estimated tf smoothing, by movmean with [x,x] values
H_11 = movmean(H_11,[2,2]);
H_21 = movmean(H_21,[2,2]);
% Estimated tf plot
figure(1)
subplot(1,2,1);
semilogx(f_H_11, mag2db(abs(H_11)), ‘b’, ‘LineWidth’, 0.7);
hold on;
subplot(1,2,2);
semilogx(f_H_21, mag2db(abs(H_21)), ‘b’, ‘LineWidth’, 0.7);
hold on;
% Frequency range to keep only relevant part of tf by tfestimate
fmin = 0.1; % min freq (Hz)
fmax = 15; % max freq (Hz)
idx_11 = (f_H_11 >= fmin) & (f_H_11 <= fmax); % frequency index in the selected range
idx_21 = (f_H_21 >= fmin) & (f_H_21 <= fmax); % frequency index in the selected range
H_11_filtered = H_11(idx_11);
f_11_filtered = f_H_11(idx_11); % corresponding frequencies
H_21_filtered = H_21(idx_21);
f_21_filtered = f_H_21(idx_21); % corresponding frequencies
% rad/s conversion to use in `idfrd`
f_11_rad = f_11_filtered * 2 * pi;
f_21_rad = f_21_filtered * 2 * pi;
% Filtered tf plot
subplot(1,2,1);
semilogx(f_11_filtered, mag2db(abs(H_11_filtered)), ‘r’, ‘LineWidth’, 0.7);
subplot(1,2,2);
semilogx(f_21_filtered, mag2db(abs(H_21_filtered)), ‘r’, ‘LineWidth’, 0.7);
% Creating an identified model based on frequency data
H_11_idfrd = idfrd(H_11_filtered, f_11_rad, ‘Ts’, 0); % continuous time
H_21_idfrd = idfrd(H_21_filtered, f_21_rad, ‘Ts’, 0); % continuous time
% tf estimation in "tf" variable type
np = 4; % system pole number
nz = 2; % system zero number
sys_est_11 = tfest(H_11_idfrd, np, nz);
sys_est_21 = tfest(H_21_idfrd, np, nz);
sys_est = [sys_est_11; sys_est_21]; % [2×1] dimension
% Estimated FRF plot
figure(2)
P = bodeoptions;
P.FreqUnits = ‘Hz’; % Frequency axys in Hz
bodeplot(sys_est, P);
grid on;
hold on;
% Print estimated tf in the Command Window
sys_est
Any help? Thank you in advance! I am using tfestimate and tfest to experimentally derive the frequency response function of a 2 dof system with 1 input and 2 output.
The problem is that tfest seems to cancel or does not recognize a complex pole pair (resonance) near a complex zero pair (antiresonance) around 6 Hz in the tf from input 1 to output 1 and consequently simplifies the frequency response of the system (see image, correct plot in blue vs simplified plot in red):
I tried different types of windowing in tfestimate but the only one that allows me to obtain the correct frequency response after tfest is rectwin without overlap: this works only with mathematical model I/O data, the blue plot shown above, but with the real model data the problem persists. Other windows like hann (which would be more suitable) also leads to a pole-zero simplification after tfest, with mathematical model I/O data too.
Increasing the number of zeros-poles from 2-4 to 6-8 tfest gives me the correct transfer functions, but I absolutely need the model with 2 zeros and 4 poles for a correct dynamic of the system to control by using the identification of its FRF.
To load I/O data see attachment .mat file
The code is the following:
% Upload I/O data
load ‘test_identificazione_chirp_tauGain_0,1.mat’
% Data from real model
th1abs = theta1_rad_MEAS.signals.values;
th2rel = theta2_rad_MEAS.signals.values;
th2abs = th1abs+th2rel;
tauIn = tauInput.signals.values;
nfs = 4096*4; % Number of samples for FFT
Fs = 1000; % Sampling frequency
% Transfer functions estimate from input 1 (tauIn) to outputs 1 and 2 (th1abs and th2abs)
[H_11, f_H_11] = tfestimate(squeeze(tauIn), squeeze(th1abs), rectwin(floor(size(squeeze(tauIn), 1))), 0, nfs*4, Fs);
[H_21, f_H_21] = tfestimate(squeeze(tauIn), squeeze(th2abs), rectwin(floor(size(squeeze(tauIn), 1))), 0, nfs*4, Fs);
% Try also hann window with overlap to get a better curve: hann(floor(size(squeeze(tauIn), 1) / 15)), 3000
% Estimated tf smoothing, by movmean with [x,x] values
H_11 = movmean(H_11,[2,2]);
H_21 = movmean(H_21,[2,2]);
% Estimated tf plot
figure(1)
subplot(1,2,1);
semilogx(f_H_11, mag2db(abs(H_11)), ‘b’, ‘LineWidth’, 0.7);
hold on;
subplot(1,2,2);
semilogx(f_H_21, mag2db(abs(H_21)), ‘b’, ‘LineWidth’, 0.7);
hold on;
% Frequency range to keep only relevant part of tf by tfestimate
fmin = 0.1; % min freq (Hz)
fmax = 15; % max freq (Hz)
idx_11 = (f_H_11 >= fmin) & (f_H_11 <= fmax); % frequency index in the selected range
idx_21 = (f_H_21 >= fmin) & (f_H_21 <= fmax); % frequency index in the selected range
H_11_filtered = H_11(idx_11);
f_11_filtered = f_H_11(idx_11); % corresponding frequencies
H_21_filtered = H_21(idx_21);
f_21_filtered = f_H_21(idx_21); % corresponding frequencies
% rad/s conversion to use in `idfrd`
f_11_rad = f_11_filtered * 2 * pi;
f_21_rad = f_21_filtered * 2 * pi;
% Filtered tf plot
subplot(1,2,1);
semilogx(f_11_filtered, mag2db(abs(H_11_filtered)), ‘r’, ‘LineWidth’, 0.7);
subplot(1,2,2);
semilogx(f_21_filtered, mag2db(abs(H_21_filtered)), ‘r’, ‘LineWidth’, 0.7);
% Creating an identified model based on frequency data
H_11_idfrd = idfrd(H_11_filtered, f_11_rad, ‘Ts’, 0); % continuous time
H_21_idfrd = idfrd(H_21_filtered, f_21_rad, ‘Ts’, 0); % continuous time
% tf estimation in "tf" variable type
np = 4; % system pole number
nz = 2; % system zero number
sys_est_11 = tfest(H_11_idfrd, np, nz);
sys_est_21 = tfest(H_21_idfrd, np, nz);
sys_est = [sys_est_11; sys_est_21]; % [2×1] dimension
% Estimated FRF plot
figure(2)
P = bodeoptions;
P.FreqUnits = ‘Hz’; % Frequency axys in Hz
bodeplot(sys_est, P);
grid on;
hold on;
% Print estimated tf in the Command Window
sys_est
Any help? Thank you in advance! tfest, system identification, frequency response MATLAB Answers — New Questions
Determine the Bode diagram or a transfer function with input output data without tfest
In a partially unknown system, I measured a square-wave signal as input and the associated system response. Now I would like to use fft() to determine the transfer function or the Bode diagram. I have attached the measurements. I have the following code (also from this forum) but it results in this very bad bode plot. where is my mistake?
input = x3bzeit((23000:39000),2);
output = x3bzeit((23000:39000),3);
time = x3bzeit((23000:39000),1)*10^(-6);
Fs = 1/mean(diff(time)); % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(time);
FTinp = fft(input)/L;
FTout = fft(output)/L;
TF = FTout ./ FTinp; % Transfer Function
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
subplot(2,1,1)
plot(Fv, 20*log10(abs(TF(Iv))))
set(gca, ‘XScale’, ‘log’)
title(‘Amplitude’)
ylabel(‘dB’)
subplot(2,1,2)
plot(Fv, angle(TF(Iv))*180/pi)
title(‘Phase’)
ylabel(‘°’)In a partially unknown system, I measured a square-wave signal as input and the associated system response. Now I would like to use fft() to determine the transfer function or the Bode diagram. I have attached the measurements. I have the following code (also from this forum) but it results in this very bad bode plot. where is my mistake?
input = x3bzeit((23000:39000),2);
output = x3bzeit((23000:39000),3);
time = x3bzeit((23000:39000),1)*10^(-6);
Fs = 1/mean(diff(time)); % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(time);
FTinp = fft(input)/L;
FTout = fft(output)/L;
TF = FTout ./ FTinp; % Transfer Function
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
subplot(2,1,1)
plot(Fv, 20*log10(abs(TF(Iv))))
set(gca, ‘XScale’, ‘log’)
title(‘Amplitude’)
ylabel(‘dB’)
subplot(2,1,2)
plot(Fv, angle(TF(Iv))*180/pi)
title(‘Phase’)
ylabel(‘°’) In a partially unknown system, I measured a square-wave signal as input and the associated system response. Now I would like to use fft() to determine the transfer function or the Bode diagram. I have attached the measurements. I have the following code (also from this forum) but it results in this very bad bode plot. where is my mistake?
input = x3bzeit((23000:39000),2);
output = x3bzeit((23000:39000),3);
time = x3bzeit((23000:39000),1)*10^(-6);
Fs = 1/mean(diff(time)); % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(time);
FTinp = fft(input)/L;
FTout = fft(output)/L;
TF = FTout ./ FTinp; % Transfer Function
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
subplot(2,1,1)
plot(Fv, 20*log10(abs(TF(Iv))))
set(gca, ‘XScale’, ‘log’)
title(‘Amplitude’)
ylabel(‘dB’)
subplot(2,1,2)
plot(Fv, angle(TF(Iv))*180/pi)
title(‘Phase’)
ylabel(‘°’) bode, transfer function, fft MATLAB Answers — New Questions
Convert a part of simulink model of my project to VHDL or Verilog code for FPGA
I have completed my direct power control for my wind energy conversion system, this is going to be implemented in hardware for this i want to generated Verilog or VHDL code of Direct Power Control to produce pulses to the Back to back converter, how to do thisI have completed my direct power control for my wind energy conversion system, this is going to be implemented in hardware for this i want to generated Verilog or VHDL code of Direct Power Control to produce pulses to the Back to back converter, how to do this I have completed my direct power control for my wind energy conversion system, this is going to be implemented in hardware for this i want to generated Verilog or VHDL code of Direct Power Control to produce pulses to the Back to back converter, how to do this fpga, verilog, vhdl MATLAB Answers — New Questions
Xlim error in App designer
% Value changing function: STARTKnob_2
function STARTKnob_2ValueChanging(app, event)
arguments
app
event.Value(1,1) {mustBeNumeric}=0
end
app.StartYear = event.Value;
if app.StartYear>app.StopYear-1 %checks the increasing-xrule
app.StopYear=min([app.StartYear+1,app.STOPKnob.Limits(2)]);
app.STOPKnob.Value=app.StopYear; %rotate the stop knob
app.StartYear=app.StopYear-1;
app.STARTKnob_2.Value=app.StartYear;
end
app.plotData();
end
% Value changing function: STOPKnob
function STOPKnobValueChanging(app, event)
arguments
app
event.Value(1,1) {mustBeNumeric}=0
end
app.StopYear = event.Value;
if app.StopYear<app.StartYear+1
app.StartYear=max([app.StopYear-1 app.STARTKnob_2.Limits(1)]);
app.STARTKnob_2.Value=app.StartYear;
app.StopYear=app.StartYear+1;
app.STOPKnob.Value=app.StopYear;
end
app.plotData();% Value changing function: STARTKnob_2
function STARTKnob_2ValueChanging(app, event)
arguments
app
event.Value(1,1) {mustBeNumeric}=0
end
app.StartYear = event.Value;
if app.StartYear>app.StopYear-1 %checks the increasing-xrule
app.StopYear=min([app.StartYear+1,app.STOPKnob.Limits(2)]);
app.STOPKnob.Value=app.StopYear; %rotate the stop knob
app.StartYear=app.StopYear-1;
app.STARTKnob_2.Value=app.StartYear;
end
app.plotData();
end
% Value changing function: STOPKnob
function STOPKnobValueChanging(app, event)
arguments
app
event.Value(1,1) {mustBeNumeric}=0
end
app.StopYear = event.Value;
if app.StopYear<app.StartYear+1
app.StartYear=max([app.StopYear-1 app.STARTKnob_2.Limits(1)]);
app.STARTKnob_2.Value=app.StartYear;
app.StopYear=app.StartYear+1;
app.STOPKnob.Value=app.StopYear;
end
app.plotData(); % Value changing function: STARTKnob_2
function STARTKnob_2ValueChanging(app, event)
arguments
app
event.Value(1,1) {mustBeNumeric}=0
end
app.StartYear = event.Value;
if app.StartYear>app.StopYear-1 %checks the increasing-xrule
app.StopYear=min([app.StartYear+1,app.STOPKnob.Limits(2)]);
app.STOPKnob.Value=app.StopYear; %rotate the stop knob
app.StartYear=app.StopYear-1;
app.STARTKnob_2.Value=app.StartYear;
end
app.plotData();
end
% Value changing function: STOPKnob
function STOPKnobValueChanging(app, event)
arguments
app
event.Value(1,1) {mustBeNumeric}=0
end
app.StopYear = event.Value;
if app.StopYear<app.StartYear+1
app.StartYear=max([app.StopYear-1 app.STARTKnob_2.Limits(1)]);
app.STARTKnob_2.Value=app.StartYear;
app.StopYear=app.StartYear+1;
app.STOPKnob.Value=app.StopYear;
end
app.plotData(); xlim error in app designer MATLAB Answers — New Questions
How can I simulate an active distribution system using the Monte Carlo method in MATLAB?
I need to simulate an article using MATLAB based on customer satisfaction using the Monte Carlo method
using by simulink or matlab code.
I know that this article doesn’t have an accurate circuit or block diagram and it should be optimized from previous sources. Assuming that a part is disconnected or connected randomly
You can see the original article here
here
anyone can help me on this ?!
best regards.I need to simulate an article using MATLAB based on customer satisfaction using the Monte Carlo method
using by simulink or matlab code.
I know that this article doesn’t have an accurate circuit or block diagram and it should be optimized from previous sources. Assuming that a part is disconnected or connected randomly
You can see the original article here
here
anyone can help me on this ?!
best regards. I need to simulate an article using MATLAB based on customer satisfaction using the Monte Carlo method
using by simulink or matlab code.
I know that this article doesn’t have an accurate circuit or block diagram and it should be optimized from previous sources. Assuming that a part is disconnected or connected randomly
You can see the original article here
here
anyone can help me on this ?!
best regards. simulink, monte carlo, active distribution networks, customer satisfaction MATLAB Answers — New Questions
add_line connection for to column cells
Hi there,
While creating column Cells connections, last cell in each column still not connected…stayed unconnected.
I wonder if someone can assist to solve this problem.
please see shared Matlab code (file.m) and picture (marked in red line)
Thanks for help
Tommy
open_system(‘Module_arc’)
mdl = ‘Module_arc’;
bat_rec_model = find_system(mdl,’FindAll’,’on’,’Name’,’Module_arc’);
%%% add Cell – basic CELL_unit:
for i=1:2 %% set two columns
colPos = 200; %% spaces between columns
for v=1:4 %% loop for 13 cells per column
nl=num2str(v + 4*(i-1));
if i==1
AddCell(v) = add_block(‘CELL_Unit/CELL 1’, [mdl,’/CELL ‘,nl]);
else
AddCell(v) = add_block(‘CELL_Unit2/CELL 1’, [mdl,’/CELL ‘,nl]);
end
posc = get(AddCell(v),’Position’);
set(AddCell(v),’Position’,posc + [100+(i-1)*colPos 120*(v-1)-45 100+(i-1)*colPos 120*(v-1)-45])
PH_AddCell{v}=get(AddCell(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_AddCell{v-1}.LConn(2),PH_AddCell{v}.LConn(1),’Autorouting’,’on’);
end
end
switch i
case 2
Minus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
PH_minus2Cell=get(Minus_2_Cell,’PortHandles’);
Neg_port= add_line(mdl,PH_minus2Cell.RConn,PH_AddCell{1}.LConn(1),’Autorouting’,’on’);
case 1
Plus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
PH_plus2Cell=get(Plus_2_Cell,’PortHandles’);
Pos_port= add_line(mdl,PH_plus2Cell.RConn,PH_AddCell{1}.LConn(1), ‘Autorouting’,’on’);
end
endHi there,
While creating column Cells connections, last cell in each column still not connected…stayed unconnected.
I wonder if someone can assist to solve this problem.
please see shared Matlab code (file.m) and picture (marked in red line)
Thanks for help
Tommy
open_system(‘Module_arc’)
mdl = ‘Module_arc’;
bat_rec_model = find_system(mdl,’FindAll’,’on’,’Name’,’Module_arc’);
%%% add Cell – basic CELL_unit:
for i=1:2 %% set two columns
colPos = 200; %% spaces between columns
for v=1:4 %% loop for 13 cells per column
nl=num2str(v + 4*(i-1));
if i==1
AddCell(v) = add_block(‘CELL_Unit/CELL 1’, [mdl,’/CELL ‘,nl]);
else
AddCell(v) = add_block(‘CELL_Unit2/CELL 1’, [mdl,’/CELL ‘,nl]);
end
posc = get(AddCell(v),’Position’);
set(AddCell(v),’Position’,posc + [100+(i-1)*colPos 120*(v-1)-45 100+(i-1)*colPos 120*(v-1)-45])
PH_AddCell{v}=get(AddCell(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_AddCell{v-1}.LConn(2),PH_AddCell{v}.LConn(1),’Autorouting’,’on’);
end
end
switch i
case 2
Minus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
PH_minus2Cell=get(Minus_2_Cell,’PortHandles’);
Neg_port= add_line(mdl,PH_minus2Cell.RConn,PH_AddCell{1}.LConn(1),’Autorouting’,’on’);
case 1
Plus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
PH_plus2Cell=get(Plus_2_Cell,’PortHandles’);
Pos_port= add_line(mdl,PH_plus2Cell.RConn,PH_AddCell{1}.LConn(1), ‘Autorouting’,’on’);
end
end Hi there,
While creating column Cells connections, last cell in each column still not connected…stayed unconnected.
I wonder if someone can assist to solve this problem.
please see shared Matlab code (file.m) and picture (marked in red line)
Thanks for help
Tommy
open_system(‘Module_arc’)
mdl = ‘Module_arc’;
bat_rec_model = find_system(mdl,’FindAll’,’on’,’Name’,’Module_arc’);
%%% add Cell – basic CELL_unit:
for i=1:2 %% set two columns
colPos = 200; %% spaces between columns
for v=1:4 %% loop for 13 cells per column
nl=num2str(v + 4*(i-1));
if i==1
AddCell(v) = add_block(‘CELL_Unit/CELL 1’, [mdl,’/CELL ‘,nl]);
else
AddCell(v) = add_block(‘CELL_Unit2/CELL 1’, [mdl,’/CELL ‘,nl]);
end
posc = get(AddCell(v),’Position’);
set(AddCell(v),’Position’,posc + [100+(i-1)*colPos 120*(v-1)-45 100+(i-1)*colPos 120*(v-1)-45])
PH_AddCell{v}=get(AddCell(v),’PortHandles’);
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_AddCell{v-1}.LConn(2),PH_AddCell{v}.LConn(1),’Autorouting’,’on’);
end
end
switch i
case 2
Minus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’NEG’);
PH_minus2Cell=get(Minus_2_Cell,’PortHandles’);
Neg_port= add_line(mdl,PH_minus2Cell.RConn,PH_AddCell{1}.LConn(1),’Autorouting’,’on’);
case 1
Plus_2_Cell = find_system(mdl,’LookUnderMasks’,’All’,’FindAll’,’on’,’Name’,’POS’);
PH_plus2Cell=get(Plus_2_Cell,’PortHandles’);
Pos_port= add_line(mdl,PH_plus2Cell.RConn,PH_AddCell{1}.LConn(1), ‘Autorouting’,’on’);
end
end matlab, simulink MATLAB Answers — New Questions
Data must be a single matrix Y or a list of pairs X,Y
My aim is to plot 2d the function ph (xx,yy) in the plane (xx,yy).
x-axis is xx, y-axis is yy, and the function ph(xx,yy)
=====================================================
q=1.0;
v=(1.0-sqrt(1.0+4.0*q))/(2.0*q);
p=4*atan(1.0);
for j=0:100
a=0.0+j.*p/100;
fori=0:100
b=0.0+i.*p/100;
x=cos(a);
y=sin(b);
z=x.*x+y.*y;
if z<1.0
xx=x;
yy=y;
zz=z;
D=1.0+q.*(v.*v)*(zz.*zz);
N=1.0-v.*zz-q.*(v.*v)*(zz.*zz);
ph=D/N;
hold on
plot(xx,yy,ph)
end
end
end
=====================================My aim is to plot 2d the function ph (xx,yy) in the plane (xx,yy).
x-axis is xx, y-axis is yy, and the function ph(xx,yy)
=====================================================
q=1.0;
v=(1.0-sqrt(1.0+4.0*q))/(2.0*q);
p=4*atan(1.0);
for j=0:100
a=0.0+j.*p/100;
fori=0:100
b=0.0+i.*p/100;
x=cos(a);
y=sin(b);
z=x.*x+y.*y;
if z<1.0
xx=x;
yy=y;
zz=z;
D=1.0+q.*(v.*v)*(zz.*zz);
N=1.0-v.*zz-q.*(v.*v)*(zz.*zz);
ph=D/N;
hold on
plot(xx,yy,ph)
end
end
end
===================================== My aim is to plot 2d the function ph (xx,yy) in the plane (xx,yy).
x-axis is xx, y-axis is yy, and the function ph(xx,yy)
=====================================================
q=1.0;
v=(1.0-sqrt(1.0+4.0*q))/(2.0*q);
p=4*atan(1.0);
for j=0:100
a=0.0+j.*p/100;
fori=0:100
b=0.0+i.*p/100;
x=cos(a);
y=sin(b);
z=x.*x+y.*y;
if z<1.0
xx=x;
yy=y;
zz=z;
D=1.0+q.*(v.*v)*(zz.*zz);
N=1.0-v.*zz-q.*(v.*v)*(zz.*zz);
ph=D/N;
hold on
plot(xx,yy,ph)
end
end
end
===================================== error in plot MATLAB Answers — New Questions
Legends using bodeplot with latex interpretation
Hi, I am trying to write code for plotting frequency responses and cannot get the legend to accept latex formatting. I know there are issues with all of these signal processing tools and stuff like legends, but if I open the figure in a new window and manually adjust the legend in the property editor then it is possible. So there must be a work around. Here is one of the many iterations I have used, in this version the legend appears, but as soon as I add interpreter to the command then I get errors such as seen below:
G1 = G(1,1);
G2 = G(1,2);
G3 = G(2,1);
G4 = G(2,2);
names = {‘$G_{11}$’, ‘$G_{12}$’, ‘$G_{21}$’, ‘$G_{22}$’};
LegendValues = string(names);
bp = bodeplot(G1, G2, G3, G4);
opts = bodeoptions;
opts.Title.String = ”; % Disable title
opts.XLabel.Interpreter = ‘latex’;
opts.XLabel.FontSize = 12;
opts.YLabel.Interpreter = ‘latex’;
opts.YLabel.FontSize = 12;
opts.PhaseVisible = ‘off’; % Hide phase plot
opts.Grid = ‘on’; % Enable grid
setoptions(bp, opts);
legend(LegendValues);
Error if I add interpreter (legend(LegendValues, "Interpreter","latex");):
"Error using legend (line 176). First argument must be text."
I appreciate any input.
MarcusHi, I am trying to write code for plotting frequency responses and cannot get the legend to accept latex formatting. I know there are issues with all of these signal processing tools and stuff like legends, but if I open the figure in a new window and manually adjust the legend in the property editor then it is possible. So there must be a work around. Here is one of the many iterations I have used, in this version the legend appears, but as soon as I add interpreter to the command then I get errors such as seen below:
G1 = G(1,1);
G2 = G(1,2);
G3 = G(2,1);
G4 = G(2,2);
names = {‘$G_{11}$’, ‘$G_{12}$’, ‘$G_{21}$’, ‘$G_{22}$’};
LegendValues = string(names);
bp = bodeplot(G1, G2, G3, G4);
opts = bodeoptions;
opts.Title.String = ”; % Disable title
opts.XLabel.Interpreter = ‘latex’;
opts.XLabel.FontSize = 12;
opts.YLabel.Interpreter = ‘latex’;
opts.YLabel.FontSize = 12;
opts.PhaseVisible = ‘off’; % Hide phase plot
opts.Grid = ‘on’; % Enable grid
setoptions(bp, opts);
legend(LegendValues);
Error if I add interpreter (legend(LegendValues, "Interpreter","latex");):
"Error using legend (line 176). First argument must be text."
I appreciate any input.
Marcus Hi, I am trying to write code for plotting frequency responses and cannot get the legend to accept latex formatting. I know there are issues with all of these signal processing tools and stuff like legends, but if I open the figure in a new window and manually adjust the legend in the property editor then it is possible. So there must be a work around. Here is one of the many iterations I have used, in this version the legend appears, but as soon as I add interpreter to the command then I get errors such as seen below:
G1 = G(1,1);
G2 = G(1,2);
G3 = G(2,1);
G4 = G(2,2);
names = {‘$G_{11}$’, ‘$G_{12}$’, ‘$G_{21}$’, ‘$G_{22}$’};
LegendValues = string(names);
bp = bodeplot(G1, G2, G3, G4);
opts = bodeoptions;
opts.Title.String = ”; % Disable title
opts.XLabel.Interpreter = ‘latex’;
opts.XLabel.FontSize = 12;
opts.YLabel.Interpreter = ‘latex’;
opts.YLabel.FontSize = 12;
opts.PhaseVisible = ‘off’; % Hide phase plot
opts.Grid = ‘on’; % Enable grid
setoptions(bp, opts);
legend(LegendValues);
Error if I add interpreter (legend(LegendValues, "Interpreter","latex");):
"Error using legend (line 176). First argument must be text."
I appreciate any input.
Marcus bodeplot, legend MATLAB Answers — New Questions
How to convert polynomial trajectory block out to a 4×4 homogeneous transformation matrix
I created 7 waypoints using inverse kinematics designer app and exported the configuration into a matrix (7×6 matrix) containg xyz position and respective euler angles. From this matrix i input only the xyz position data(3×7 matrix) as waypoints to a polynomial trajectory block with time. But when i run the simulink an error is showing up, saying that polynomial trajectory output should be 4×4 homogeneous matrix inorder to connect to the inverse kinematics block input (pose). How could I resolve this issueI created 7 waypoints using inverse kinematics designer app and exported the configuration into a matrix (7×6 matrix) containg xyz position and respective euler angles. From this matrix i input only the xyz position data(3×7 matrix) as waypoints to a polynomial trajectory block with time. But when i run the simulink an error is showing up, saying that polynomial trajectory output should be 4×4 homogeneous matrix inorder to connect to the inverse kinematics block input (pose). How could I resolve this issue I created 7 waypoints using inverse kinematics designer app and exported the configuration into a matrix (7×6 matrix) containg xyz position and respective euler angles. From this matrix i input only the xyz position data(3×7 matrix) as waypoints to a polynomial trajectory block with time. But when i run the simulink an error is showing up, saying that polynomial trajectory output should be 4×4 homogeneous matrix inorder to connect to the inverse kinematics block input (pose). How could I resolve this issue polynomial trajectory, inverse kinematics, simulink MATLAB Answers — New Questions
how to find the accuracy from the predicted labels for test data in Matlab?
I am using classification learner app svm generated code for the classification of multiclass dataset.
Now I wanted to test with the unseen dataset for this I am using yfit.
Now I got the predicted labels for the test data. How to find the test accuracy and from the predicted laebls?
Can someone please help me in this.I am using classification learner app svm generated code for the classification of multiclass dataset.
Now I wanted to test with the unseen dataset for this I am using yfit.
Now I got the predicted labels for the test data. How to find the test accuracy and from the predicted laebls?
Can someone please help me in this. I am using classification learner app svm generated code for the classification of multiclass dataset.
Now I wanted to test with the unseen dataset for this I am using yfit.
Now I got the predicted labels for the test data. How to find the test accuracy and from the predicted laebls?
Can someone please help me in this. calculate test data accuracy MATLAB Answers — New Questions