Borrar filtros
Borrar filtros

Surface plot for two variable piecewise function

3 visualizaciones (últimos 30 días)
Briana Canet
Briana Canet el 21 de Oct. de 2023
Comentada: Dyuman Joshi el 21 de Oct. de 2023
I need help plotting the following piecewise function in Matlab as surface plot. Any help is appreciated!!
x1 and x2 are [0,1]
  3 comentarios
Briana Canet
Briana Canet el 21 de Oct. de 2023
x1 and x2 are from 0 to 1.
Torsten
Torsten el 21 de Oct. de 2023
Then you can follow @Dyuman Joshi 's hints.

Iniciar sesión para comentar.

Respuestas (1)

Dyuman Joshi
Dyuman Joshi el 21 de Oct. de 2023
Utilize meshgrid to generate the points and evaluate the function using the points.
Then employ surf to plot the piecewise function.
  9 comentarios
Torsten
Torsten el 21 de Oct. de 2023
Editada: Torsten el 21 de Oct. de 2023
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 el 21 de Oct. de 2023
"A bracket around 1/3 was missing."
Ah, that should be it.

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by