Measuring length with polar coordinates.
4 ビュー (過去 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
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 件のコメント
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
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 Center および File Exchange で Get Started with Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!