Modified contour plot with different functions

I was wondering how to create a contour plot with the following specifications:
I have two variables x and y and two functions of these variables f(x,y) and g(x,y) and I want to plot f(x,y) in a contour plot. However I want to highlight those areas where g(x,y)>f(x,y). Of course I could graph something like h = g-f and see where it is positive but I think the first option is better. I would very much appreciate if someone could help me with this.

 채택된 답변

KSSV
KSSV 2019년 5월 8일

1 개 추천

[X,Y,Z] = peaks(100) ; % let this be g
idx = Z>3 & Z<5 ; % a given condition
contour(X,Y,Z)
hold on
plot(X(idx),Y(idx),'*r')

댓글 수: 6

I see your point, but the condition I need is based on another function, so that I can't really implement this. Any idea of how could I express that: idx = Z > F ?
Thank you very much.
KSSV
KSSV 2019년 5월 8일
편집: KSSV 2019년 5월 8일
I can't really implement this why not?
It is straighforward as I have shown the above code.
idx = Z>F ;
The logical condition returns a matrix idx with 0's and 1's whereas X and Y are vectors, therefore they're out of the arrays bounds.
KSSV
KSSV 2019년 5월 8일
sconvert x,y to matrices.....using meshgrid.
Got it! Thank you very much :)
KSSV
KSSV 2019년 5월 8일
Thanks is accepting the answer..:)

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

추가 답변 (0개)

카테고리

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

태그

질문:

2019년 5월 8일

댓글:

2019년 5월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by