matlab问题:用surf和surfc绘图是不是必须用meshgrid定义变量
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/07/30 07:01:07
matlab问题:用surf和surfc绘图是不是必须用meshgrid定义变量
例如我这有写的话:
x1=2000:5:3600;
x2=2000:5:3600;
f=70*x1+120*x2;
surfc(x1,x2,f);
提示错误:Error using ==> surfc at 42
The surface Z must contain more than one row or column.
但是我用meshgrid的话没有问题,程序如下:
[x1,x2]=meshgrid(2000:5:3600);
f=70*x1+120*x2;
surfc(x1,x2,f);
请问这是什么原因?当使用surf和surfc时是不是必须用meshgrid?不用的话怎么定义变量?
例如我这有写的话:
x1=2000:5:3600;
x2=2000:5:3600;
f=70*x1+120*x2;
surfc(x1,x2,f);
提示错误:Error using ==> surfc at 42
The surface Z must contain more than one row or column.
但是我用meshgrid的话没有问题,程序如下:
[x1,x2]=meshgrid(2000:5:3600);
f=70*x1+120*x2;
surfc(x1,x2,f);
请问这是什么原因?当使用surf和surfc时是不是必须用meshgrid?不用的话怎么定义变量?
![matlab问题:用surf和surfc绘图是不是必须用meshgrid定义变量](/uploads/image/z/8655262-70-2.jpg?t=matlab%E9%97%AE%E9%A2%98%EF%BC%9A%E7%94%A8surf%E5%92%8Csurfc%E7%BB%98%E5%9B%BE%E6%98%AF%E4%B8%8D%E6%98%AF%E5%BF%85%E9%A1%BB%E7%94%A8meshgrid%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F)
surf和surfc是网格绘图,所以用的数据必须是meshgrid生成的数据,或者是二维矩阵