从matlab绘图中获取平均值?
当我有图表时,我有一个简单的图,其中包含大量数据点。有没有一种方法可以让我简单地单击所有这些点并让 matlab 给出它们的平均值?
谢谢
I have a simple plot which feature a lot of data points, when i have have graph. Is there a way that i can simple click on all these point and allow matlab to give me a average value of them?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
另一种选择是使用数据刷。
单击图形工具栏上的画笔图标并进行选择。然后在菜单中选择“工具”-“刷子”-“创建新变量”。您可以保留默认变量名称
ans
。该变量将包含所有选定点的 X 和 Y 坐标。然后只需运行mean(ans(:,2))
即可获得 Ys 的平均值。Another option is to use data brush.
Click brush icon on the figure toolbar and make a selection. Then select in menu Tools-Brushing-Create new variable. You can leave default variable name
ans
. This variable will contain X and Y coordinates of all selected points. Then just runmean(ans(:,2))
to get average of Ys.如果您不想以编程方式执行此操作,最简单的方法是使用数据刷和统计数据。
我使用plot(rand(1,200)) 来生成数据。绘制完成后,转到“工具”>“数据统计。 Y-mean 就是您正在寻找的。
替代文本 http://www.thinkextensely.com/misc/stackoverflow/images/ matlab2.png”
要获取特定数据集的平均值,请选择所需的数据,然后在菜单中转到“工具”>“ 。刷牙>创建新变量。 。 ..这将创建一个包含装箱数据的变量。要获取平均值,请执行
mean(ans)
。向量中的第二个值是 Y 均值。替代文本 http://www.thinkextensely.com/misc/stackoverflow/images/ matlab1.png
The easiest way if you don't want to do it programmatically would be to use the data brush and statistics.
I used
plot(rand(1,200))
to generate my data. After it has plotted go to Tools > Data Statistics. Y-mean is what you are looking for.alt text http://www.thinkextensively.com/misc/stackoverflow/images/matlab2.png
To get the mean of a specific set of data, select the data you want, then in the menu go to Tools > Brushing > Create New Variable . . .. This creates a variable containing the boxed data. To get the mean do
mean(ans)
. The second value in the vector is the Y-mean.alt text http://www.thinkextensively.com/misc/stackoverflow/images/matlab1.png
不太清楚您想要计算的值的平均值。我认为,它是 y 坐标。
我将使用 RBBOX 函数来选择绘图上的点集。
试试这个代码:
我必须声明这个代码的大部分来自 rbbox 文档。
Not very clear average of what values you wanted to calculate. I assume, it's y-coordinates.
I would use RBBOX function to select set of points on the plot.
Try this code:
I have to claim large portion of this code is from rbbox documentation.
我猜您想根据已绘制的数据绘制平均值(或至少计算它)。
使用 plotAverage 来自 Matlab 文件交换,您可以轻松完成。
I guess that you want to plot an average (or at least calculate it) from already plotted data.
With plotAverage from the Matlab File Exchange, you can do it quite easily.