Measuring length with polar coordinates.
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
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
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
