Borrar filtros
Borrar filtros

How to create a graph with X, Y + Contour Axes.

2 visualizaciones (últimos 30 días)
Al Onen
Al Onen el 20 de Feb. de 2012
Editada: Matt J el 25 de Oct. de 2013
Hello, I need some guidance for creating a very similar chart shown below in the link.
For each axis, including the contoured one, I also have some data between 0-1 (actally % values) of corresponding type and I am supposed to show them in a single chart. I am not sure about how to combine those different values into one. If someone can offer some guidance with key functions, I would be greatly faithful.
Thanks in advance.

Respuesta aceptada

the cyclist
the cyclist el 20 de Feb. de 2012
Here is a simple example, which I hope you can bend to your needs. I adapted it from the documentation here: http://www.mathworks.com/help/techdoc/ref/contour.html. I think it illustrates most of what you want, including how to overlay multiple plots (with the hold command), adding labels to the contours, etc. There are help files for all the different functions I used, of course.
figure
hold on
[X,Y] = meshgrid(-2:.2:2,-2:.2:3);
Z = X.*exp(-X.^2-Y.^2);
[C,h] = contour(X,Y,Z);
set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2)
addedRandomX = rand(1,20);
addedRandomY = rand(1,20);
plot(addedRandomX, 1+addedRandomY,'kx')
plot(-addedRandomX,1+addedRandomY,'ro')
  5 comentarios
the cyclist
the cyclist el 26 de Feb. de 2012
The reason you got the mldivide error when calculating Z is that you were using the syntax for matrix division, where you actually wanted element-by-element division.
Try this instead:
figure
hold on
[X,Y] = meshgrid(-2:.2:2,-2:.2:3);
Z = 1./((1./(1-Y))+(1./X)-1);
[C,h] = contour(X,Y,Z)
Notice that I added "./" in place of just "/". The dots are the syntax for element-by-element operations.
I'm not sure if the result is what you expect, but at least it executes.
Al Onen
Al Onen el 26 de Feb. de 2012
Thank you so much. Indeed it works - I'm such a loser with Matlab. :) I have to keep the purpose of dots in mind. Now the answer is officially accepted.

Iniciar sesión para comentar.

Más respuestas (1)

Al Onen
Al Onen el 21 de Feb. de 2012
Thank you, that will probably do the trick.

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by