在matlab中使用SURF实时绘图



我想在matlab中使用surf绘制3d图形。我知道如何使用surf:

绘制它
k = 5;
n = 2^k-1;
[x,y,z] = sphere(n);
c = hadamard(2^k);
p=surf(x,y,z);

,但我想实时绘制它,我想使用set更新值。我累了:set(p,"XData",Xvalue,"YData",Yvalue,"ZData",Zvalue);,但它给我错误。有人用实时冲浪绘图吗?

1)您可以使用linkdata命令或工具栏按钮(甚至工具->链接从绘图窗口)

2)编程:你需要调用命令'refreshdata'来表示新数据可用:

%% Define the data
t=linspace(0,2*pi,40);
y=sin(t);
%% Create the plot and set teh datasources
h=plot(t,y)
set(h,'YDataSource','y')
set(h,'XDataSource','t')
%% Now update the data and the plot
pause
y=sin(2*t);
refreshdata

这显示了plot,但期望surf的行为相同。

最新更新