How to plot for this function?

1 次查看(过去 30 天)
clear all
close all
clc
x = 0:100;
y = linspace(50,150,101)
[X,Y] = meshgrid(x,y);
f = cos((pi.*x)./50).*sin((pi.*y)./100);
surf(X,Y,f)

采纳的回答

Rik
Rik 2021-1-22
编辑:Rik 2021-1-22
You forgot to use the variables you just created:
x = 0:100;
y = linspace(50,150,101);
[X,Y] = meshgrid(x,y);
f = cos((pi.*X)./50).*sin((pi.*Y)./100);
% ^ not x, but X ^ not y, but Y
surf(X,Y,f)
You should also avoid the habit of starting your code with clear all,close all,clc. Especially that first one should be avoided. During debugging you can use clear or clearvars to remove variables, otherwise use functions.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by