Why do my axis change dimensioins?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi All, this code is supposed to plot a 3D surface and a contour plot of the function with wells at (-2, 2) and (3, -1). However, when I run the code, firstly, the wells are not in the right places, and the dimensions of the axis change as my inputs for x and y change (ie the position of the wells change). What am I doing wrong?
Here is my code,
function M = landscape(x, y)
M = H1(x, y) + H2(x, y);
function h1 = H1(x, y)
R1 = 2;
s1 = [-2;2];
n1 = 2;
h1 = (1./(1+(R1./sqrt((x-s1(1)).^2+(y(:)-s1(2)).^2)).^n1));
end
function h2 = H2(x, y)
R2 = 1;
s2 = [3;-1];
n2 = 1;
h2 = (1./(1+(R2./sqrt((x-s2(1)).^2+(y(:)-s2(2)).^2)).^n2));
end
subplot(1, 2, 1)
surf(M)
subplot(1, 2, 2)
contour(M)
end
And two different graphs the first with x and y -5:5 and the second with x and y -10:10
Notice how the position of the wells change?
0 件のコメント
採用された回答
Steven Lord
2019 年 10 月 19 日
What happens, according to the documentation, when you call surf with one input argument? What does surf use for the X and Y coordinates at which to place the points that make up the surface?
Try calling surf with three input arguments instead.
The same applies to the contour function. You called it with one input when you should be calling it with three.
その他の回答 (0 件)
参考
カテゴリ
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!