How can I redo it by using for loop
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!