Creating 3d surfaces from two independent functions
1 view (last 30 days)
Show older comments
Michael Pegis
on 22 May 2020
Commented: Michael Pegis
on 28 May 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!
0 Comments
Accepted Answer
John D'Errico
on 22 May 2020
Edited: John D'Errico
on 22 May 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)
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!