Get data in real time, draw graphics changing in real time.
1 次查看(过去 30 天)
显示 更早的评论
Hi, I'm getting real-time data from the manipulator, its current position.
channel = ddeinit('ipc_data', 'ipc_1');
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
I need to represent the manipulator's position on the chart. and when the manipulator moves, it should be evident in the chart.
0 个评论
采纳的回答
Paulo Silva
2011-4-12
clf
p=plot3(nan,nan,nan);
while 1
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
set(p,'XData',[0 data(1,1)],'YData',[0 data(1,2)],'ZData',[0 data(1,3)])
pause(0.5) %read and draw data every 0.5 seconds
end
To stop the loop do CTRL+C
Alternative way, using a timer:
function test
fig=figure;
set(fig,'CloseRequestFcn','delete(gcf);')
h = plot3(NaN, NaN, NaN,'LineWidth',5);
t = timer('TimerFcn',@readdata,...
'Period', 0.5,'executionmode','fixedSpacing');start(t)
function readdata(g1,gg1)
if (~ishandle(fig)),stop(t),return,end
data(1,1)=ddereq(channel,'mw1311'); % X coordinate
data(1,2)=ddereq(channel,'mw1312');% Y coordinate
data(1,3)=ddereq(channel,'mw1313');% Z coordinate
set(p,'XData',[0 data(1,1)],'YData',[0 data(1,2)],'ZData',[0 data(1,3)])
end
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Instrument Control Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!