Plot a function of two variables
73 ビュー (過去 30 日間)
古いコメントを表示
I want to plot the function sin(4*pi*x)*sin(4*pi*y).
I tried the following but I am not sure if I am doing the right thing. Any help will be appreciated. Thanks
h = 2/11;
x = -1+h:h:1-h;
y = x;
[X,Y] = meshgrid(x,y);
z = @(x,y) sin(4*pi*x).* sin(4*pi*y); % Create Function
plot(x, z(X,Y))
2 件のコメント
Cris LaPierre
2021 年 3 月 13 日
編集済み: Cris LaPierre
2021 年 3 月 13 日
What are you trying to do? Describe that, and then we can tell you if you are doing the right thing.
採用された回答
Cris LaPierre
2021 年 3 月 13 日
I think you want to plot a surface rather than a line plot. Use surf with inputs X, Y and z. This will allow you to see the response over the full X-Y parameter space. Since the number of points will affect the resolution of this surface, I use linspace instead of the colon operator.
h = 2/11;
x = linspace(-1+h,1-h,50);
y = x;
[X,Y] = meshgrid(x,y);
z = @(x,y) sin(4*pi*x).* sin(4*pi*y); % Create Function
surf(X,Y,z(X,Y))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!