How can I redo it by using for loop
Afficher commentaires plus anciens
function [x,y] = butterfly_function(tmin,tmax,dt,s,x0,y0)
%BUTTERFLY_FUNCTION Summary of this function goes here
% Detailed explanation goes here
t=tmin:dt:tmax;
f=exp(cos(t))-2*cos(4*t)-(sin(t/12)).^5;
x=x0+(s.*f.*sin(t));
y=y0+(s.*f.*cos(t));
end
---------------------------------
Matlab code for main program
-----------------
tmin=0;
tmax=40*pi;
dt=0.001;
s=0.1;
x0=1;
y0=1;
[x,y] = butterfly_function(tmin,tmax,dt,s,x0,y0);
plot(x,y,'b')
axis([0 4 0 4])
axis equal
hold on
s=0.4;
x0=2.5;
y0=1;
[x,y] = butterfly_function(tmin,tmax,dt,s,x0,y0);
plot(x,y,'r')
hold on
s=0.2;
x0=0.5;
y0=3;
[x,y] = butterfly_function(tmin,tmax,dt,s,x0,y0);
plot(x,y,'k')
hold on
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Whos dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!