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.

 Akzeptierte Antwort

KSSV
KSSV am 8 Mai 2019
[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 Kommentare

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 am 8 Mai 2019
Bearbeitet: KSSV am 8 Mai 2019
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 am 8 Mai 2019
sconvert x,y to matrices.....using meshgrid.
Got it! Thank you very much :)
KSSV
KSSV am 8 Mai 2019
Thanks is accepting the answer..:)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Contour Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 8 Mai 2019

Kommentiert:

am 8 Mai 2019

Community Treasure Hunt

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

Start Hunting!

Translated by