Measuring length with polar coordinates.
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
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
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 diff function and “vpaintegral” function.
- https://www.mathworks.com/help/matlab/ref/diff.html
- https://www.mathworks.com/help/symbolic/sym.vpaintegral.html
Hope this helps!
댓글 수: 5
Benjamin
2024년 1월 29일
Fantastic works well thank you so much. I checked this with my own less effecient code, and got very close answers.
@Milan Bansal if the range instead of an angle is a length, how can i configure this code to calculate the length over a variable length range. Ie the variable lin =(0;10) mm
Benjamin
2024년 1월 29일
i tried this: @Milan Bansal
%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);
but I get the error: Error using symengine
Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute values for
variables.
Xstr = mupadmex('symobj::double', S.s, 0);
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
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개)
카테고리
도움말 센터 및 File Exchange에서 Assembly에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
