appending data to scatter(x,y)
古いコメントを表示
I am n random points in two dimensional space (x,y). I am using scatter(x,y) to visualize them.
Now I want to take the center of mass of these points (x,y) with a formula, and now I want to append them to the scatter(x,y). There are now n+1 points. How do I do this, aside from using 'hold on'?
Your insights would be great
採用された回答
その他の回答 (1 件)
Will Reeves
2022 年 3 月 16 日
編集済み: Will Reeves
2022 年 3 月 16 日
I would like to add scatter points to a plot during a loop to visualise the process I'm running.
I currently use hold on, and scatter the new point every time it's created, or destroyed. Unfortunately, the way Matlab handles (excuse the pun) scatter plots is fine if you are scattering a large number of points at once. If you're scattering one point at a time it eats memory like a monster if you have a few thousand individual scatter points. (I got to 20GB quickly then my PC ground to a stop!).
It would be lovely to have a feature where you can add data to a dataset or scatter plot and have it "add" the point, rather than creating a whole new object. For instance
sp=scatter(data(:,1),data(:,2));
then add a point to the data, then
sp.update
or something?
Of course this leads to another issue in Matlab whereby "adding extra points to arrays" is horrifically slow, and pre-allocation is fine if you already know the outcome. It would be lovely to have the "list functionality" that other languages have where you can efficiently add data to a list without reallocation - obviously a list object wouldn't be as fast at other types of computation though appreciated.
カテゴリ
ヘルプ センター および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!