contour plot usage of argument v

I am new to Matlab and I am learning the plot function 'contour'. One usage of it showed on the documentation is contour(X,Y,Z,v), the explanation of the argument v is not very clear in the documentation, could somebody give a thoughtful explanation and example on the usage of contour(X,Y,Z,v)?

답변 (2개)

KSSV
KSSV 2016년 8월 10일

0 개 추천

v is used to specify the contour levels...Check the following code....it might clear you the concept..
clc ; clear all ;
x = -3:0.125:3;
y = -3:0.125:3;
[X,Y] = meshgrid(x,y);
Z = peaks(X,Y);
for i = 1:10
v = 1:i ;
contour(X,Y,Z,v) ;
fprintf('v is from %d to %d',1,i) ;
drawnow
pause(0.1)
end

댓글 수: 2

Yi Yang
Yi Yang 2016년 8월 10일
Could you please be more specific on the 'level'? What if the elements in v are decimals? How are the levels calculated for a contour?
KSSV
KSSV 2016년 8월 11일
It does interpolation and gets levels which does not exist....

댓글을 달려면 로그인하십시오.

Star Strider
Star Strider 2016년 8월 10일

0 개 추천

The ‘v’ argument is a vector of values at which the contour lines are drawn, rather than having contour choose them.
Using an example from the documentation:
x = -3:0.125:3;
y = -3:0.125:3;
[X,Y] = meshgrid(x,y);
Z = peaks(X,Y);
v = [-3, -1, -0.5, 0.5, 5, 7];
figure
contour(X,Y,Z,v, 'ShowText','on')
This is especially useful for getting the zeros of a bivariate function:
x = -3:0.125:3;
y = -3:0.125:3;
[X,Y] = meshgrid(x,y);
Z = peaks(X,Y);
v = [0, 0];
figure
contour(X,Y,Z,v)

카테고리

도움말 센터File Exchange에서 Contour Plots에 대해 자세히 알아보기

제품

태그

질문:

2016년 8월 10일

댓글:

2016년 8월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by