
plotting a function with input and output
조회 수: 6 (최근 30일)
이전 댓글 표시
here is my code. hw prompt below. what do you recommend i do?
t=0:0.01*pi:20*pi;
function [x,y]=bird(t)
x(t)=sin(t)*(e.^cos(t) -2*cos(4*t)-sin.^5(t/12))
y(t)=cos(t)*(e.^cos(t) -2*cos(4*t)-sin.^5(t/12))
plot(x,y)

댓글 수: 0
채택된 답변
Image Analyst
2020년 12월 8일
You need to change * to .* and change e to exp(), and you need to move the 5 exponent:
t=0:0.01*pi:20*pi; % Create t
[x, y] = bird(t); % Call the function.
function [x,y] = bird(t)
x = sin(t) .* (exp(cos(t)) - 2*cos(4*t)-sin(t/12).^5)
y = cos(t) .* (exp(cos(t)) - 2*cos(4*t)-sin(t/12).^5)
plot(x,y)
end

댓글 수: 0
추가 답변 (1개)
David Hill
2020년 12월 8일
Main script
t=0:.01*pi:20*pi;
[x,y]=bird(t);
plot(x,y);
function
function [x,y]=bird(t)
x=sin(t).*(exp(cos(t)) -2*cos(4*t)-sin(t/12).^5);
y=cos(t).*(exp(cos(t)) -2*cos(4*t)-sin(t/12).^5);
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Transforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!