How to create this "bean shape" in MatLab please?

4 Ansichten (letzte 30 Tage)
Charles
Charles am 11 Okt. 2023
Kommentiert: Image Analyst am 12 Okt. 2023
Please see the attached screenshot for reference (the shape does not have to be exactly the same as the screenshot)
I am trying to create this shape, or a similar "bean" shape in MatLab. Thank you for your help.
  1 Kommentar
Les Beckham
Les Beckham am 11 Okt. 2023
If you are just getting started with Matlab, I would highly recommend that you take a couple of hours to go through the free online tutorial: Matlab Onramp
What have you tried so far?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 11 Okt. 2023
Try this:
t = linspace(0, 2*pi, 1000);
x = 3 + 2 * sin(t) + cos(2 * t);
y = 4 * cos(t) - sin(2*t);
plot(x, y, 'b-', 'LineWidth', 2)
grid on;
xlabel('x');
ylabel('y');
axis equal
xlim([-.25, 5]);
ylim([-5, 5]);
To learn other fundamental concepts, invest 2 hours of your time here:
  2 Kommentare
Charles
Charles am 12 Okt. 2023
Awesome! Thank you for the help.
Most of my MatLab models use the "surf" and "fsurf" functions, so that is what I am more comfortable with.
I see that you used the "plot" function, so thank you for showing me this alternative method.
Follow-up question: Is there any way to add a z-dimension to your "plot" function? From what I learned, perhaps "plot3" would be the one to use. Thank you.
Image Analyst
Image Analyst am 12 Okt. 2023
You can use plot3 if you have some z value for each "t" value.
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Objects finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by