No Line in my plot its just dots
Show older comments

This is my finished work buy it just shows the dots not the line, how can I display it?
x=0.5;
n=5;
i=0;
f=0;
while i<n || i==n
f= f+(x.^i)/factorial(i);
i=1+i;
f_o=exp(x);
y=(f_o-f)*100/f_o;
disp(['Term ',num2str(i), ' The error is ',num2str(y,'%.4f'),'%']);
plot(f,y,'*r','LineWidth',1)
hold on
grid on
end
Thank you
Accepted Answer
More Answers (1)
Star Strider's approach is the one I'd probably use if all I cared about what that the line was plotted, not necessarily when it was plotted.
But if you need each point to appear in its corresponding iteration of the loop, create an animatedline prior to the loop and addpoints to it.
x = 0:360;
y = sind(x);
h = animatedline;
axis([0 360 -1 1])
for whichPoint = 1:numel(x)
addpoints(h, x(whichPoint), y(whichPoint))
end
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!