Plotting graph from the data

Post your MATLAB discussions here
Post Reply
phunzaixian
Newbie
Posts: 0
Joined: Thu Oct 25, 2012 2:27 am

Plotting graph from the data

Post by phunzaixian »

Hi,

My code is able to stream the data from the picolog series and I would like to plot a graph based on the data streamed.
(Not after all the data collected but for each data collected it will start to plot the point)

Code: Select all

clc;clear;
pause on;

%---------- Load PicoLog 1000 series Library ----------%
%loadlibrary('PL1000.dll','pl1000Api.h');
loadlibrary 'PL1000.dll' 'pl1000Api.h' addheader 'picoStatus.h';
if ~libisloaded('PL1000')
    error('Library pl1000.dll or pl1000Api.h not found') %Check if library file loaded 
end

%------------ Define pointer and variables ------------%
 handle       = libpointer('int16Ptr',zeros(1,1));  % short handle
 string1      = '';
 rSize1       = 20;
 stringLength = 20;
 BM_STREAM    = 2;

 us_for_block       = 1000000; % Set for 1 second 
 ideal_no_of_sample = 1000;    % 1000 sample/second
 no_of_value        = 1000;    % number of sample that should be captured 
% nSampleCollected = libpointer('uint32Ptr',0); % for pl1000GetValues
 nSampleCollected   = 1;
 pbuffer1     = libpointer('uint16Ptr',zeros(1,1)); % buffer value
 overflow     = 0;
 trig         = 0;
 channel      = 1; % is using channel 1
 IsReady      = 0; % use for pl1000Ready
 nline        = 0; % use for pl1000GetValues loop

%--------------------    Program    -------------------%
% -- Open and enumerate the unit -- 
[status_open, handle] = calllib('PL1000', 'pl1000OpenUnit', handle); 
fprintf('Opening the device \n');

% -- Get information of the device --
[status_getVariant, string1, rSize1] = calllib('PL1000','pl1000GetUnitInfo', handle, string1, stringLength, rSize1, 3);
fprintf('%s \n',string1);

% -- Set trigger mode (disable) --
[status_trigger] = calllib('PL1000','pl1000SetTrigger', handle, 0,0,0,0,0,0,0,0);

% -- Set sampling mode (channel and time persample) --
% Set for 1000 sample every 1 second on channel 1
[status_interval] = calllib('PL1000','pl1000SetInterval',handle, us_for_block, ideal_no_of_sample, channel,1);
  
% -- Run --
% Set for 1000 samples (1000 sample/second) on streaming mode
[status_run] = calllib('PL1000','pl1000Run', handle, no_of_value, BM_STREAM);
 
% -- Is the device ready ? -- 
while IsReady == 0
        [status_ready, IsReady] = calllib('PL1000','pl1000Ready', handle, IsReady);
end
% -- If the device ready, get the values --
while nline ~= 100
% channel 1, number of samples should be collected    
 [status_getValue, pbuffer1, nSamplePerChannel, overflow, trig ] = calllib('PL1000','pl1000GetValues', handle, pbuffer1, nSampleCollected, overflow, trig);
% Display the value in Matlab Command Window 
 fprintf('%d  C1= %f Overflow= %f\n',nline,pbuffer1,overflow);
 nline = nline + 1;
% Delay for 1 second 
 pause(1); 
end
pause off;

% -- Abort data collection --
[status_stop] = calllib('PL1000','pl1000Stop', handle);
 
%----------------   Unload the library  ---------------% 
unloadlibrary ('PL1000');
I was told that the drawnow function in matlab would help me with the problem, could you elaborate more? Tq

Hitesh

Re: Plotting graph from the data

Post by Hitesh »

Hi,

I'm also interested in how this would be implemented.

I've had a quick search and found the following:

http://www.mathworks.co.uk/matlabcentra ... hread/2739

http://www.mathworks.co.uk/matlabcentra ... ead/155564

http://www.mathworks.co.uk/matlabcentra ... ead/240065



Please note that Pico Technology is not responsible for the content of external web sites.

Post Reply