Making a simple flower

28 views (last 30 days)
Gashi on 6 Jan 2022
Edited: KSSV on 7 Jan 2022
I need to make the exact same flower like on the picture. Hope someone could help me out. Thank you!

John D'Errico on 6 Jan 2022
Edited: John D'Errico on 6 Jan 2022
What did you try? As it is, all we are asked to do is to write a complete code to solve your problem. And we don't do that here. (Since this is surely part of your homework or a student project of some sort.)
The solution is a simple one. Break ANY large problem down into small ones. Solve each small problem, one at a time. Then solve the large problem, by combining the small pieces into a whole. So...
1. Write a code that will draw a circle of known radius and center in a figure.
2. Write a code that will draw an ellipse, of known major and minor axes, at a given inclination and center, again, drawing the result in a figure.
3. Finally, draw all 12 ellipses necessary, as well as the circle in one figure. Remember to use hold on to force the next curve to appear on the same set of axes.
(1) may be trivial for you, or possibly not. Only you know if that is true. In fact, a circle is just a simple version of an ellipse. So if you can solve the general ellipse problem, then you have solved the large part of this problem.
So if (2) is still too difficult, that is, to draw one ellipse, then break it down. First, find a reference that explains how to draw an ellipse. I would suggest looking for the equation of an ellipse in polar coordinates.
IF an inclined ellipse is too difficult at first, then figure out how to draw an ellipse that is NOT at an inclined angle. Then figure out how to rotate it. I'm sorry, but homework is designed to make YOU think, not for you to be given the answer on a platter.
Steven Lord on 6 Jan 2022
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB. One of the sections covers the basics of plotting data.

Image Analyst on 6 Jan 2022
See my ellipse demos and adapt as needed.

KSSV on 7 Jan 2022
Edited: KSSV on 7 Jan 2022
@John D'Errico I have seen this question whence asked. Worked on it yesterday and could not upload that time and left home from office. As the answer was ready, I am answering it now.
% define angle
t = linspace(0,2*pi) ;
xc = cos(t) ; yc = sin(t) ;
% define ellipse centers
m = 12 ;
th = linspace(0,2*pi,m) ;
cx = 4.*cos(th) ;
cy = 4.*sin(th) ;
% Define ellipse
a = 2 ; b = 1/2 ;
xe = a*cos(t) ;
ye = b*sin(t) ;
P = [xe;ye] ;
figure
axis equal
hold on
plot(xc,yc)
for i = 1:m
% Rotation matrix
R = [cos(th(i)) -sin(th(i)) ;
sin(th(i)) cos(th(i))] ;
% Rotate the ellipse
Pr = R*P ;
x = cx(i)+Pr(1,:) ;
y = cy(i)+Pr(2,:) ;
% plot ellipse
plot(x,y) ;
end
axis([-6 6 -6 6])
box on

Community Treasure Hunt

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

Start Hunting!

Translated by