2012-07-27 65 views
0

如何在Matlab中繪製兩個變量的用戶定義函數?如何繪製在Matlab中定義的兩個變量的函數

+1

,你可能會發現這個[情節畫廊(http://www.mathworks.com/discovery/ gallery.html)有用(點擊任何情節,你會看到代碼來產生它)。在你的情況下,這將是[曲面圖](http://www.mathworks.com/matlabcentral/fileexchange/35305-matlab-plot-gallery-surface-plot-1/content/html/Surface_Plot_1.html) – Amro 2012-07-27 00:57:34

回答

1
X, Y = meshgrid(xs, ys); % values of x and y at which we want to evaluate 
Z = my_func(X,Y); 
surf(X,Y,Z); 

另外,如果你的函數沒有矢量化,

X, Y = meshgrid(xs, ys); % values of x and y at which we want to evaluate 
for x = 1:length(xs) 
    for y = 1:length(ys) 
    Z(x,y) = my_func(X(x,y), Y(x,y)); 
    end 
end 
Z = my_func(X,Y); 
surf(X,Y,Z); 
1

ezsurf是一個簡單的解決方案,或ezmesh,或ezcontour,或ezsurfc,或ezmeshc。

0

它有很多類型。

你可以去積庫,並選擇您的變量,然後類型,如網眼,3D,表面,...

相關問題