How to plot a "Bean-shaped" object in MatLab please? (preferably a parametric equation)

Please see the screenshot attached
(This is the general shape that I would like to create in MatLab please, but the shape or equation does not have to be exactly like this one)
If anyone can please help me understand how to create a similar-looking "bean-shaped" equation in MatLab, that would be amazing. Thank you for your help.
  • Preferably defined by parametric equations please (I usually define shapes in MatLab parametrically, such as drawing a "cardioid" or "limacon")
  • Preferably it is plotted using "surf" (but fsurf or another method also works)

 Accepted Answer

Change the equation as per requirement -
a = 3.6;
f = @(x,y) (a*x+x.^2+y.^2).^2 - a^2*y;
fimplicit3(f)
Experiment with view to change the field of view.

4 Comments

Hello, thank you! This is very nice, and it exactly matches the one I showed in the screenshot.
However, is there any way to define this object/mesh using the "surf" function please?
I see that you used the "fimplicit3" function to create this. It is still good and I appreciate the help, but it would even better if "surf" or "fsurf" was used. This is because I am more familiar with those functions and it would be more compatible with my other models. Thank you.
@Charles, the equation you have is an implicit equation, thus I have used fimplicit3. surf or fsurf are better suited for explicit equations.
And fimplicit is from the same family of functions as surf and fsurf, so it will be compatible with your other models as well.
Oh, I see. That makes sense. Thank you for the clarification. You explained it well. Thank you.
You are welcome!
If my answer solved your problem, please consider accepting the answer.

Sign in to comment.

Products

Release

R2023a

Community Treasure Hunt

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

Start Hunting!