Why doesnt my code plot?
이전 댓글 표시
Hello, I have a problem with the following code;
x=linspace(0,2*pi,100);
for t=1:length(x)
f=@(x) 2+sin(5*x(t)+2.2.*cos(5.*x(t))); hold on
plot(x,f(x),'b')
end
If i change in the plot argument to 'bo-' I get alot of wierd lines of circles not in par with what im trying to accomplish, namely to plot the function r(t)=2+sin(5t+2.2cos(5t)), 0<t<2pi.
채택된 답변
추가 답변 (1개)
Image Analyst
2017년 10월 13일
Try this:
x=linspace(0,2*pi,100);
y = zeros(1, length(x));
f=@(x, t) 2+sin(5*x(t)+2.2.*cos(5.*x(t)));
for t=1:length(x)
t
y(t) = f(x, t);
plot(x(1:t), y(1:t), 'b*-')
hold on
grid on;
drawnow;
pause(0.1);
end
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!