how to do Real time data collection via lan?
Show older comments
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
Titus Edelhofer
on 26 Jul 2012
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.
Walter Roberson
on 29 Jul 2012
What errors and warnings are you getting?
Walter Roberson
on 30 Jul 2012
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" ?
Answers (0)
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!