how to do Real time data collection via lan?

hi all,
I am doing an project based on real time data collection via lan. though we have toolboxes and blocksets for doing this. since, i supposed to do it with m-file. anyhow, i tried it well. but, getting some errors and warnings. it will be very helpful, if you some experts suggest me a right way.
and my code is,
interfaceObject=tcpip('192.168.1.1',80); %this is my server IP address.
figureHandle = figure('NumberTitle','off',...
'Name','Live Data Stream Plot',...
'Color',[0 0 0],...
'CloseRequestFcn',{@localCloseFigure,interfaceObject});
axesHandle = axes('Parent',figureHandle,...
'YGrid','on',...
'YColor',[0.9725 0.9725 0.9725],...
'XGrid','on',...
'XColor',[0.9725 0.9725 0.9725],...
'Color',[0 0 0]);
xlabel(axesHandle,'Number of Samples');
ylabel(axesHandle,'Value');
hold on;
plotHandle = plot(axesHandle,0,'-y','LineWidth',1);
bytesToRead = 500;
interfaceObject.BytesAvailableFcn = {@localReadAndPlot,plotHandle,bytesToRead};
interfaceObject.BytesAvailableFcnMode = 'byte';
interfaceObject.BytesAvailableFcnCount = bytesToRead;
fopen(interfaceObject);
pause(3);
snapnow;
function localReadAndPlot(interfaceObject,~,figureHandle,bytesToRead)% herr, this function is not supporting. how sholud i do then?
data = fread(interfaceObject,bytesToRead);
function localCloseFigure(figureHandle,~,interfaceObject)% here also...
fclose(interfaceObject);
delete(interfaceObject);
clear interfaceObject;
delete(figureHandle);

3 Comments

Please edit your question to show the code as code (e.g. by indenting the first line by two spaces or using the code buttons). Otherwise it's hardly readable.
What errors and warnings are you getting?
Thank you for reformatting, but you still need to tell us what errors and warnings you are getting. For example, how do you know that "herr, this function is not supporting" ?

Sign in to comment.

Answers (0)

Categories

Asked:

on 26 Jul 2012

Community Treasure Hunt

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

Start Hunting!