Creating 3d surfaces from two independent functions

2 Ansichten (letzte 30 Tage)
Michael Pegis
Michael Pegis am 22 Mai 2020
Kommentiert: Michael Pegis am 28 Mai 2020
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!

Akzeptierte Antwort

John D'Errico
John D'Errico am 22 Mai 2020
Bearbeitet: John D'Errico am 22 Mai 2020
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)

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by