How to calculate integral along the boundary of closed curve?

5 ビュー (過去 30 日間)
Romuald Kuras
Romuald Kuras 2018 年 9 月 3 日
コメント済み: Romuald Kuras 2018 年 9 月 3 日
Hi!
I would like to calculate the area under the curve (in direction to Z axis - see the attachment file), which is formed of discrete values on the edge of a closed curve. I have an idea, but it is a quite arduous method (using 'trapz' function), does anyone have any other suggestions?
Thanks in advance!
  4 件のコメント
Torsten
Torsten 2018 年 9 月 3 日
Take the sum of
sqrt((x(i+1)-x(i))^2+(y(i+1)-y(i))^2)*(z(i)+z(i+1))/2
Best wishes
Torsten.
Romuald Kuras
Romuald Kuras 2018 年 9 月 3 日
Thanks a lot! I never dreamed that I would get the answer so quickly :)

サインインしてコメントする。

採用された回答

Dimitris Kalogiros
Dimitris Kalogiros 2018 年 9 月 3 日
編集済み: Dimitris Kalogiros 2018 年 9 月 3 日
Provided than (x,y) points are very dense you can approximate the area you ask, good enough:
clear; clc;
% generation of input data
t=0:0.01:2*pi-0.01;
x=4*cos(t);
y=2*sin(t);
z=sqrt(abs(x))+y.^2+exp(0.6*x);
stem3(x,y,z,'-b'); hold on;
plot3(x,y,0*z,'-k.'); hold on;
plot3(x,y,z,'r*');
xlabel('x'); ylabel('y'); zlabel('z');
% calculation of area (approximately)
A=0;
for n=1:length(x)-1
A= A+ sqrt( (x(n+1)-x(n))^2 + (y(n+1)-y(n))^2 ) * (z(n)+z(n+1))/2 ;
end
fprintf('Area is %f \n', A)
If you run this script, you will receive something like this:
  1 件のコメント
Romuald Kuras
Romuald Kuras 2018 年 9 月 3 日
Thank you so much! I did not expect that I would get the answer so quickly and that someone will create a similar function for the clarity of the problem. Thanks a lot! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by