for idx = 1 hold on plot(idx,density(idx),"*") hold off pause(0.2) end showing incorrect
2 views (last 30 days)
Show older comments
Name your loop counter idx. For the first execution of the loop, idx should have a value of 1, and it should increase by 1 each consecutive iteration.
0 Comments
Answers (3)
KSSV
on 6 Jul 2022
density = density(:) ;
idx = (1:length(density))' ;
figure
plot(idx,density)
comet(idx,density)
0 Comments
Yogesh
on 22 Apr 2025
density = density(:) ;
idx = (1:length(density))' ;
figure
plot(idx,density)
comet(idx,density
1 Comment
Walter Roberson
on 22 Apr 2025
@Yogesh What difference is there between this answer and the one @KSSV posted nearly three years ago, https://www.mathworks.com/matlabcentral/answers/1754580-for-idx-1-hold-on-plot-idx-density-idx-hold-off-pause-0-2-end-showing-incorrect#answer_1001425
See Also
Categories
Find more on Numeric Types 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!