How can i draw Butterflies like this

Answers (1)

Well they pretty much told you how to do it step by step. To get t I'd use colons:
t = 0 : dt : 40*pi;
To plot in red or black, use
plot(x, y, 'r-', 'LineWidth', 2); % Red line
plot(x, y, 'k-', 'LineWidth', 2); % Black line
What more help do you need?

4 Comments

Arif Bilkay
Arif Bilkay on 14 Jun 2020
Edited: Arif Bilkay on 14 Jun 2020
function [x, y] = butterfly_function(tmin, tmax, dt, s, xo, yo)
t=tmin:dt:tmax;
f=exp(cos(t))-2.*cos(4.*t)-(sin(t./12)).^5;
x=xo+s.*f.*sin(t);
y=yo+s.*f.*cos(t);
end
tmin=0;
tmax=40*pi;
dt=0.001;
s=0.1;
xo=1;
yo=1;
[x, y] = butterfly_function(tmin, tmax, dt, s, xo, yo)
plot(x,y,'b');
axis([0 4 0 4])
axis equal
hold on;
s=0.2;
xo=3;
yo=3;
[x, y] = butterfly_function(tmin, tmax, dt, s, xo, yo)
plot(x,y,'r');
axis([0 4 0 4])
axis equal
hold on;
s=0.4;
xo=2.5;
yo=1;
[x, y] = butterfly_function(tmin, tmax, dt, s, xo, yo)
plot(x,y,'g');
axis([0 4 0 4])
axis equal
hold on;
end
OK, so did that work? (I haven't tried it).
Yeah! It finally happened. Thank you so much for helping :))
You're welcome. Could you then "Accept this answer" as additional thanks. Thanks in advance.

Sign in to comment.

Categories

Find more on Graphics in Help Center and File Exchange

Asked:

on 14 Jun 2020

Commented:

on 15 Jun 2020

Community Treasure Hunt

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

Start Hunting!