필터 지우기
필터 지우기

How can I get the zero crossing contour of a matrix

조회 수: 20 (최근 30일)
harsha
harsha 2023년 2월 12일
댓글: harsha 2023년 2월 13일
Hi,
I have a matrix of 201x201 size and it has a zero crossing. I am using contour3 to get the contour plot. but i actually need only the contour corresponding to zero values. the image it attached here.
any help would be highly appreciated.
Thank you.

채택된 답변

John D'Errico
John D'Errico 2023년 2월 12일
편집: John D'Errico 2023년 2월 12일
help contourc
CONTOURC Contour computation. CONTOURC computes the contour matrix C for use by CONTOUR, CONTOUR3, or CONTOURF to draw the actual contour plot. C = CONTOURC(Z) computes the contour matrix for a contour plot of matrix Z treating the values in Z as heights above a plane. A contour plot is the set of level curves of Z for some values V. The values V are chosen automatically. C = CONTOURC(X, Y, Z), where X and Y are vectors, specifies the X- and Y-axes limits for Z. CONTOURC(Z, N) and CONTOURC(X, Y, Z, N) compute N contour lines, overriding the automatic value. CONTOURC(Z, V) and CONTOURC(X, Y, Z, V) compute LENGTH(V) contour lines at the values specified in vector V. Use CONTOURC(Z, [v, v]) or CONTOURC(X, Y, Z, [v, v]) to compute a single contour at the level v. The contour matrix C is a two row matrix of contour lines. Each contiguous drawing segment contains the value of the contour, the number of (x, y) drawing pairs, and the pairs themselves. The segments are appended end-to-end as C = [level1 x1 x2 x3 ... level2 x2 x2 x3 ...; pairs1 y1 y2 y3 ... pairs2 y2 y2 y3 ...] See also CONTOUR, CONTOURF, CONTOUR3. Documentation for contourc doc contourc
For example:
v = linspace(-5,5,100);
[x,y] = meshgrid(v,v);
z = x.^2 - y.^2 + 1; % The contours will be hyperbolic
contour(x,y,z,[0,0])
C = contourc(v,v,z,[0 0])
C = 2×354
0 -4.8990 -4.7980 -4.7958 -4.6970 -4.6926 -4.5960 -4.5892 -4.4949 -4.4858 -4.3939 -4.3822 -4.2929 -4.2785 -4.1919 -4.1747 -4.0909 -4.0707 -3.9899 -3.9666 -3.8889 -3.8623 -3.7879 -3.7578 -3.6869 -3.6532 -3.5859 -3.5483 -3.4848 -3.4432 176.0000 5.0000 4.9011 4.8990 4.8022 4.7980 4.7034 4.6970 4.6048 4.5960 4.5062 4.4949 4.4077 4.3939 4.3094 4.2929 4.2112 4.1919 4.1131 4.0909 4.0152 3.9899 3.9174 3.8889 3.8198 3.7879 3.7224 3.6869 3.6252 3.5859
There will be two contour lines found, each of which have 176 points in the piecewise curves generated.
So if you want the points along that contour itself, contourc does it. If you want to draw the contour, then I contour will do it easily enough.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by