フィルターのクリア

How to get the accurate coordinate value of the point on a fitted contour? And how to integrate along the contour?

4 ビュー (過去 30 日間)
Hello!
I am in trouble with processing data with matlab.
The mesh is two dimensional and each grid point has its function value f.
In matlab, the iso-surface of f=0 can be fitted with the command 'contour';
Then the question is,
1) Given an x coordinate value, how to get the accurate y coordinate value of the point on the fitted contour?
2) In order to get the accurate length of the total contour, how to integrate along the contour?
dx=dy=0.001m
For a random x coordinate value, for example x=0.00875, how to get the corresponding y coordinate value on the contour f=0?
And how to get the accurate length of the total red contour line?
==============================================================================
Data=load('shuju.dat');
x=Data(:,1);
y=Data(:,2);
f=Data(:,5);
xx=reshape(x,301,43);
yy=reshape(y,301,43);
ff=reshape(f,301,43);
v=[0,0];
contour(xx,yy,ff,v,'r','LineWidth',2);
xlabel('x/m');
ylabel('y/m');
========================================================================
Thanks!

採用された回答

Roger Stafford
Roger Stafford 2014 年 11 月 29 日
You can obtain a two-row matrix, C, from your call to 'contour' which contains x,y coordinates for points along contours:
C = contour(xx,yy,ff,v,'r','LineWidth',2);
It is called a "contour matrix".
For 2) to integrate along the contour, just use as arclengths the euclidean linear distance between successive points as contained in C. For the format of C see the site:
http://www.mathworks.com/help/matlab/ref/contour-properties.html#prop_ContourMatrix
If the contour takes a jump as appears to happen in your case, you can eliminate all segments whose lengths are larger than some predetermined amount.
For 1) it would be a matter of finding corresponding y values for an x value which lies within some segment of the contour as given in C. In your case there will be more than one y for some x's.
  3 件のコメント
Roger Stafford
Roger Stafford 2014 年 12 月 9 日
Yes, you could use matlab's 'interp2' with your original meshgrid for that purpose. See
http://www.mathworks.com/help/matlab/ref/interp2.html

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

その他の回答 (2 件)

Ren Zetian
Ren Zetian 2014 年 11 月 28 日
Some details are added, thanks!

Ren Zetian
Ren Zetian 2014 年 12 月 8 日
Some details are added, thanks!

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by