|
"Attila Kovacs" <kovacsek71.removeThis@gmail.com> wrote in message <hr4d89$o3h$1@fred.mathworks.com>...
> I am collecting signal from two potentiometers via an NI A/D board. I would like to present real-time feedback by plotting one signal against the other (lissajous figure)always using one pair of datapoints. To this end I use peekdata function and plot the returned values. The problem I run into is that peekdata does not return every single value and therefore the display is jumping between the values returned by peekdata. I would appreciate any suggestions on how to make the display move smoother. This occurs regardless the sampling frequency.
>
> tempairunning=airunning;
>
> if airunning==0;
> start(ai)
> airunning=1;
> end
>
> running=1;
> set(stop_button,'Visible','On');
> set(start_button,'Visible','Off');
>
> % find channels to display
> for ii=1:num_channel
> onchannel(ii)=get(channel_check(ii),'Value');
> end
> goodchannel=find(onchannel==1);% logical operator
>
> pause(1)
> %-------------------------------------------
> data=peekdata(ai,1)
> %-------------------------------------------
>
> hLine=[];
> %--------------------------------------------
> for ii=1:length(goodchannel)
> hLine(ii)=line('Parent',haxes,...
> 'XData',data(:,1),...
> 'YData',data(:,2));
> end
> %--------------------------------------------
> while running==1
>
> if airunning==0;
> start(ai)
> end
> %-------------------------------------------
> data=peekdata(ai,1)
> %-------------------------------------------
> hLine=[];
> %-----------------------------------------------------
> for ii=1:length(goodchannel)
> hLine(ii)=line('Parent',haxes,...
> 'XData',data(:,1),...
> 'YData',data(:,2),...
> end
> %---------------------------------------------------------
> plot(data(:,1),data(:,2),'ro','MarkerEdgeColor','r',...
> 'MarkerFaceColor',[.49 1 .63],...
> 'MarkerSize',10);
> xlim([-5 5]);
> ylim([-5 5]);
> drawnow
>
> end
Look at the second input argument to peekdata:
you're running:
>>peekdata(obj, 1); %Here ai is your obj
if you want 1000 samples:
>>peekdata(obj, 1000);
Of course this will return an error if there are <1000 samples.
You can ensure available samples with:
obj.SamplesAvailable
Good Luck!
|