how to draw surface
显示 更早的评论
how do I write the program that draws the two-dimensional integral surface of the function in Matlab ?采纳的回答
Ameer Hamza
2020-5-8
编辑:Ameer Hamza
2020-5-8
You can draw it using meshgrid and surf
[X, Y] = meshgrid(linspace(-3,3));
Z = exp(-X.^2-Y.^2);
surf(X,Y,Z)
shading interp

9 个评论
Thank You but I need the surface of the function's integral.
But the limits on the integral are constant. They need to be variable to plot a surface. Can you show which limits of the integral are varying?
limits given from 0 to 2
Ameer Hamza
2020-5-8
编辑:Ameer Hamza
2020-5-8
I guess you want something like this
[X, Y] = meshgrid(linspace(0,2));
fun = @(X,Y) integral2(@(x,y) exp(-x.^2-y.^2), 0, X, 0, Y);
Z = arrayfun(fun, X, Y);
surf(X,Y,Z)
shading interp

yes but gives error on Line 3.
There was a typo. Try again.
Thank you very much, it works.
I am glad to be of help.
FYI, this is a faster version of the previous code in the comment
syms x y X Y
fun = matlabFunction(int(int(z,x,0,X),y,0,Y), 'Var', {X, Y});
[Xg, Yg] = meshgrid(linspace(0,2));
Z = arrayfun(fun, Xg, Yg);
surf(Xg,Yg,Z)
shading interp
更多回答(0 个)
类别
在 帮助中心 和 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!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
