Effacer les filtres
Effacer les filtres

Get data in real time, draw graphics changing in real time.

4 vues (au cours des 30 derniers jours)
Modestas Sekreckis
Modestas Sekreckis le 12 Avr 2011
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.

Réponse acceptée

Paulo Silva
Paulo Silva le 12 Avr 2011
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

Plus de réponses (0)

Catégories

En savoir plus sur Visual Exploration dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by