在MATLAB中将绘图数据与颜色和尺寸来源链接 [英] Linking plotted data with color and size sources in MATLAB

查看:106
本文介绍了在MATLAB中将绘图数据与颜色和尺寸来源链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与此处中发布的问题有关.我概述了在仿真过程中在MATLAB中快速可视化3D散点图数据时遇到的问题. (示例代码和数据也在此处提供.)

This question is related to the question posted here, in which I outline a problem I'm facing regarding rapid visualization of 3D scatter plotted data in MATLAB during a simulation. (Sample code and data are also provided there.)

作为在MATLAB中设置3D散点图的XDataYDataZDataSizeDataCData属性的一种替代方法,我想知道是否有可能将所有它们的动态地链接到绘制3D散点的点.链接的值将排队进入缓冲区并定期绘制(例如,每0.5 s)绘制一次.据我了解,源在后台刷新,因此带有链接数据的绘图不会降低模拟速度.根据我在文档中看到的内容,仅指定了XDataSourceYDataSourceZDataSource.是否可以动态链接大小和颜色数据源,如果没有,是否有简单的解决方法?

As an alternative to setting the XData, YData, ZData, SizeData, and CData properties of a 3D scatter plot in MATLAB, I'm wondering if it's possible to have all of their corresponding sources be dynamically linked to points that are 3D scatter plotted. The linked values would be queued into a buffer and plotted periodically (say, every 0.5 s). From what I understand, the sources are refreshed in the background, so plots with linked data would not slow down the simulation. From what I see in the documentation, only XDataSource, YDataSource, and ZDataSource are specified. Is dynamically linking the size and color data sources also possible, and if not, is there a simple workaround?

提醒一下,我在Windows 7上使用MATLAB R2016a.

As a reminder, I'm using MATLAB R2016a on Windows 7.

推荐答案

是否还可以动态链接尺寸和颜色数据源,如果没有,是否有简单的解决方法?

Is dynamically linking the size and color data sources also possible, and if not, is there a simple workaround?

是的,可以使用名称相似的属性

Yes, it is possible using the similarly named properties

  • SizeDataSource
  • CDataSource
  • SizeDataSource
  • CDataSource

这些属性设置为要链接进行更新的变量的字符串名称.然后,在链接后,对这些命名变量的后续更新将以1/2秒左右的速度(最快)反映在您的绘图中.

These properties are set to the string names of the variables you want linked for updating. Then, with linking on, subsequent updates to these named variables will be reflected in your plots ever 1/2 second or so (at the fastest).

但是,这里有一个特别的警告.

But, there is a big caveat here with your specific example.

xxxxSource字段通常在创建图形手柄时一开始就进行初始化.这将在您最初的scatter3调用中.

The xxxxSource fields are typically initialized at the outset, when a graphic handle is created. This would be in your initial scatter3 calls.

问题是您有八个单独的散点图句柄,每个句柄都引用相同的变量,但具有不同的索引.也就是说,您正在将索引更新到这些变量中以生成图像.

The issue is that you have eight separate scatter plot handles, each referencing the same variable(s), but with different indexes. That is, you are updating the indices into these variables to produce your images.

在这里使用参数链接的一种蛮力方法是创建八个不同的变量名称,并将每个变量名称链接到其对应的散点图句柄.

A brute force way to use parameter linking here would be to create eight different variable names and link each to its corresponding scatter plot handle.

我认为更干净的解决方案是使用计时器回调在设定的时间间隔上更新内容.

I think the cleaner solution is to use a timer callback to update things on a set time interval.

这篇关于在MATLAB中将绘图数据与颜色和尺寸来源链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆