필터 지우기
필터 지우기

Surface plot for two variable piecewise function

조회 수: 3 (최근 30일)
Briana Canet
Briana Canet 2023년 10월 21일
댓글: Dyuman Joshi 2023년 10월 21일
I need help plotting the following piecewise function in Matlab as surface plot. Any help is appreciated!!
x1 and x2 are [0,1]
  댓글 수: 3
Briana Canet
Briana Canet 2023년 10월 21일
x1 and x2 are from 0 to 1.
Torsten
Torsten 2023년 10월 21일
Then you can follow @Dyuman Joshi 's hints.

댓글을 달려면 로그인하십시오.

답변 (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