How to plot contour of three parameters in two dimensions?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I am wondering if it is possible to plot magnitude of events along with their latitudes and longitudes in a contour plot? I have gotten code for contours to run successfully a few times, but this only works when I write the Z as a function of x and y. However, in what I am trying to achieve, the three variables are independent of each other. I think this could work if I tried a 3D Contour plot, but I am trying to plot in 2 Dimensions, so I do not think contour3 is an option.
I am attaching a simplified version of my code to show what I am trying to achieve. Thank you!
x = 1;
y = 4;
z = 5;
[X, Y]= meshgrid(x, y);
contour(X,Y,z)
Error using contourf (line 57)
Z must be at least a 2x2 matrix.
0 Kommentare
Antworten (1)
Shweta Singh
am 28 Jun. 2018
'contour' and 'contour3' can work with independent Z as long as all the conditions are satisfied. For instance, X,Y can't be scalars and Z must be at least a 2x2 matrix. Read this documentation for details and exact working of this function: https://www.mathworks.com/help/matlab/ref/contour.html
Following is a working code:
x = [1 2];
y = [1 3];
[X,Y] = meshgrid(x,y);
z = [2 5];
Z = diag(z);
contour(X,Y,Z)
Hope this helps!
1 Kommentar
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!