Creating 3d surfaces from two independent functions

조회 수: 1 (최근 30일)
Michael Pegis
Michael Pegis 2020년 5월 22일
댓글: Michael Pegis 2020년 5월 28일
Hello,
I am generating two 3d (mesh) plots for two separate functions, and I need to find a way to plot both of these on the same graph with certain bounds. Specifically, I need to find a way to do this, without just playing with the function output range to "hide" the other function under certain x,y ranges
lets say f1 = (x^2) and f2 = (x-5)^2 [I am just adimensionalizing this into 2d space for simplicity]
I need to turn the left figure into the right one.
Is there a way to do this easily, in particular for when f1 = (x,y) and f2 = (x,y) and the functions look much less simple?
I imagine there may be a way to define the output so the domain where (x,y) result in f1 < f2, it choses f1 but if (x,y) result in f2<f1, it chooses f2.
Thanks for your help!

채택된 답변

John D'Errico
John D'Errico 2020년 5월 22일
편집: John D'Errico 2020년 5월 22일
Why is this not just
f3 = @(x,y) min(f1(x,y),f2(x,y));
You want the result which is the smaller of two functions.
In your example:
f1 = @(x) x.^2;
f2 = @(x) (x-5).^2;
f3 = @(x) min(f1(x),f2(x));
fplot(f3)
  댓글 수: 1
Michael Pegis
Michael Pegis 2020년 5월 28일
thank you so much, John! Very happy with the final product : )

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

추가 답변 (0개)

카테고리

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