How to plot contour of three parameters in two dimensions?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Shweta Singh
2018 年 6 月 28 日
'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!
参考
カテゴリ
Help Center および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!