Measuring length with polar coordinates.

5 次查看(过去 30 天)
I have polar coordinate functions that describe segments of a coil using Z, R and phi as the variables. I want to measure how long the coil is using these functions. Here is an example:
  1 个评论
Mathieu NOE
Mathieu NOE 2024-1-17
hello
convert your polar coordinates in cartesian x,y,z
then you know that the curve length increment ds is given by :
ds = sqrt(dx² + dy² + dz²)
compute dx,dy,dz from x,y,z using diff function and then do the summation
s = sum(ds)

请先登录,再进行评论。

采纳的回答

Milan Bansal
Milan Bansal 2024-1-25
Hi Benjamin,
As per my understanding, you want to calculate the length of the coil using polar coordinates (cylindrical coordinates). The coordinates of the coil "Z", "R" and "Phi" are described as function of parameter "alpha" which varies from 0 to "alpha_c".
To measure the length of a coil represented in cylindrical coordinates as functions of a parameter "alpha", specify the functions Z_func(alpha) , R_func(alpha), and phi_func(alpha) that describe the coil. The length of the coil can be calculated by integrating the arc length differential along the path parameterized by "alpha".
Please refer to the following steps to calculate the length of the coil using polar coordinates:
% 1. Define alpha as symbolic expression
syms alpha;
% 2. Define the symbolic functions for Z, R and phi
% Replace these with your actual functions
Z = Z_func(alpha); % Example function for Z
R = R_func(alpha); % Example function for R
phi = sin(alpha); % Example function for phi
% 3. Compute the derivatives of Z, R, and phi with respect to alpha using "diff" function.
dZ_dalpha = diff(Z, alpha);
dR_dalpha = diff(R, alpha);
dphi_dalpha = diff(phi, alpha);
% 4. Define the differential arc integral.
integrand = sqrt(dR_dalpha^2 + (R * dphi_dalpha)^2 + dZ_dalpha^2);
% 5. Calculate the symbolic integration. "vpaintegral" function calculates approximate definite integrals.
alpha1 = 0; % Replace with your actual starting value of alpha
alpha2 = 2*pi; % Replace with your actual ending value of alpha
% 6. Compute arc length
arc_length_sym = vpaintegral(integrand, alpha, alpha1, alpha2);
% Convert the symbolic arc length to a numeric value
arc_length = double(arc_length_sym);
Please refer to the following documentation links to learn more about difffunction and “vpaintegral function.
Hope this helps!
  5 个评论
Dyuman Joshi
Dyuman Joshi 2024-1-30
There are undefined variables in your code, so we can not run it and reproduce the error you got.
%segment 3
% 1. Define alpha as symbolic expression
syms l;
% 2. Define the symbolic functions for Z, R and phi
% Replace these with your actual functions
Z = Z0+l*sin(alphaCR)*cos(alphaS); % Example function for Z
Unrecognized function or variable 'Z0'.
R = R0+(Z-Z0)*tan(alphaS); % Example function for R
phi = phi0+(l/Rt)*cos(alphaCR); % Example function for phi
% 3. Compute the derivatives of Z, R, and phi with respect to alpha using "diff" function.
dZ_dl = diff(Z, l);
dR_dl = diff(R, l);
dphi_dl = diff(phi, l);
% 4. Define the differential arc integral.
integrand = sqrt(dR_dl^2 + (R * dphi_dl)^2 + dZ_dl^2);
% 5. Calculate the symbolic integration. "vpaintegral" function calculates approximate definite integrals.
l1 = 0; % Replace with your actual starting value of alpha
l2 = lin; % Replace with your actual ending value of alpha
% 6. Compute arc length
arc_length_sym = vpaintegral(integrand, l, l1, l2)
% Convert the symbolic arc length to a numeric value
arc_length3 = double(arc_length_sym)
Z0=Z0+lin*sin(alphaCR)*cos(alphaS);
R0=R0+(Z-Z0)*tan(alphaS);
phi0=phi0+(lin/Rt)*cos(alphaCR);
Benjamin
Benjamin 2024-1-30
%Value Inputs: All inputs are in radians and millimetres
Qs=96; %no. of stator slots
Lfe=400; %core length
hw=1; %height of wedge
ho=1; %height of slot opening
D1=735; %core id
hd=1;%middle strip depth
hwi=1;%wedge packer depth
hi=1;%aux wedge packer depth
hc=22.106;%coil stack height
bc=11.328;%voil stack width
y1s=10;%no. slots per coil span
bs=(pi*D1*y1s)/Qs;% total coil span
Rp=40;%coil exit bend pin radius
Rl=25;%radius coil loop
llin=10;%length between stator and coil curvature
Rc=Rp+0.5*bc;%Coil slot exit bend radius
alphaedegrees=10;%angle of bevelling of coil loop
alphae= deg2rad(alphaedegrees);%radians version
bi=4.5; %legspace
taus=(pi*D1)/Qs;%slot pitch
alphac=asin((bc+bi)/taus);%angle of coil involutes
alphaprimec=(pi/2)-alphac;%central angle of coil curvature
alphaS=(2*pi)/Qs;%extension of winding overhang
lin=(bs-4*Rc*(1-sin(alphac))-2*Rl*sin(alphae))/(2*cos(alphaS));%length of involute
alphaCR=atan(tan(alphac)*cos(alphaS));%real angle of the coil involute
%segment 1
Z=llin;
Rt=D1/2 + ho+hw+hwi+hi+hc/2;
R=Rt;
phi=0;
Z0=Z;
R0=R;
phi0=phi;
arclength1=llin
%segment 2
% 1. Define alpha as symbolic expression
syms alpha;
% 2. Define the symbolic functions for Z, R and phi
% Replace these with your actual functions
Z = Z0+Rc*sin(alpha)*cos(alphaS); % Example function for Z
R = R0+(Z-Z0)*tan(alphaS); % Example function for R
phi = phi0+(Rc/Rt)*(1-cos(alpha)); % Example function for phi
% 3. Compute the derivatives of Z, R, and phi with respect to alpha using "diff" function.
dZ_dalpha = diff(Z, alpha);
dR_dalpha = diff(R, alpha);
dphi_dalpha = diff(phi, alpha);
% 4. Define the differential arc integral.
integrand = sqrt(dR_dalpha^2 + (R * dphi_dalpha)^2 + dZ_dalpha^2);
% 5. Calculate the symbolic integration. "vpaintegral" function calculates approximate definite integrals.
alpha1 = 0; % Replace with your actual starting value of alpha
alpha2 = alphaprimec; % Replace with your actual ending value of alpha
% 6. Compute arc length
arc_length_sym = vpaintegral(integrand, alpha, alpha1, alpha2);
% Convert the symbolic arc length to a numeric value
arc_length2 = double(arc_length_sym)
Z0=Z0+Rc*sin(alphaprimec)*cos(alphaS);
R0=R0+(Z-Z0)*tan(alphaS);
phi0=phi0+(Rc/Rt)*(1-cos(alphaprimec));
%segment 3
% 1. Define alpha as symbolic expression
syms l;
% 2. Define the symbolic functions for Z, R and phi
% Replace these with your actual functions
Z = Z0+l*sin(alphaCR)*cos(alphaS); % Example function for Z
R = R0+(Z-Z0)*tan(alphaS); % Example function for R
phi = phi0+(l/Rt)*cos(alphaCR); % Example function for phi
% 3. Compute the derivatives of Z, R, and phi with respect to alpha using "diff" function.
dZ_dl = diff(Z, l);
dR_dl = diff(R, l);
dphi_dl = diff(phi, l);
% 4. Define the differential arc integral.
integrand = sqrt(dR_dl^2 + (R * dphi_dl)^2 + dZ_dl^2);
% 5. Calculate the symbolic integration. "vpaintegral" function calculates approximate definite integrals.
l1 = 0; % Replace with your actual starting value of alpha
l2 = lin; % Replace with your actual ending value of alpha
% 6. Compute arc length
arc_length_sym = vpaintegral(integrand, l, l1, l2);
% Convert the symbolic arc length to a numeric value
arc_length3 = double(arc_length_sym)
Z0=Z0+lin*sin(alphaCR)*cos(alphaS);
R0=R0+(Z-Z0)*tan(alphaS);
phi0=phi0+(lin/Rt)*cos(alphaCR);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Symbolic Math Toolbox 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by