Surface plot for two variable piecewise function

2 次查看(过去 30 天)
I need help plotting the following piecewise function in Matlab as surface plot. Any help is appreciated!!
x1 and x2 are [0,1]

回答(1 个)

Dyuman Joshi
Dyuman Joshi 2023-10-21
Utilize meshgrid to generate the points and evaluate the function using the points.
Then employ surf to plot the piecewise function.
  9 个评论
Torsten
Torsten 2023-10-21
编辑:Torsten 2023-10-21
A bracket around 1/3 was missing. Should be
U = @(x1,x2) (1-exp(-5*(x1.^3+x2.^2).^(1/3))-(1-exp(-5))) .* (((x1.^3 + x2.^2) >= 0) & ((x1.^3 + x2.^2) <= 1)) + (x1.^3 + x2.^2 - 1) .* (((x1.^3 + x2.^2) >= 1) & ((x1.^3 + x2.^2) <= 2));
figure
fsurf(U, [ 0 1 0 1], 'MeshDensity',75)
Dyuman Joshi
Dyuman Joshi 2023-10-21
"A bracket around 1/3 was missing."
Ah, that should be it.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by