From: Rod Gramlich on
I, as many in here seem to be:), am new to MATLAB. I have installed a
NI PCI-6036 DAQ. I now have the board working fine, and talking to it
with MATLAB. My aim is to use the board as a monitor (of a voltage
level), and then watch for threshold crossings and procede with some
ao and dio calls. I want to see the data (PLOTTED)in real time
(doesn't matter if I miss 'samples'). I'm currently using
getsamples(obj), and plotting them fine (but that is only a 1x1
matrix). This may sound stupid and naive, but HOW ON GOD'S EARTH DO I
JOIN THE DATA POINTS TOGETHER ON THE PLOT (i.e. make a continuous
line ???) ..... note that I'm looping the getsample 100 times or so
(i.e. currently plotting 100 points per run) - but can NOT plot a
continuous line. If it's multiple element vectors, then using a 'r-'
makes a line, but when I'm adding single points one at a time, I
can't get a continuous line. HELP !!
From: Randy Poe on

Rod Gramlich wrote:
> I, as many in here seem to be:), am new to MATLAB. I have installed a
> NI PCI-6036 DAQ. I now have the board working fine, and talking to it
> with MATLAB. My aim is to use the board as a monitor (of a voltage
> level), and then watch for threshold crossings and procede with some
> ao and dio calls. I want to see the data (PLOTTED)in real time
> (doesn't matter if I miss 'samples'). I'm currently using
> getsamples(obj), and plotting them fine (but that is only a 1x1
> matrix). This may sound stupid and naive, but HOW ON GOD'S EARTH DO I
> JOIN THE DATA POINTS TOGETHER ON THE PLOT (i.e. make a continuous
> line ???) ..... note that I'm looping the getsample 100 times or so
> (i.e. currently plotting 100 points per run) - but can NOT plot a
> continuous line. If it's multiple element vectors, then using a 'r-'
> makes a line, but when I'm adding single points one at a time, I
> can't get a continuous line. HELP !!

Add each new data point to vectors of x and y components.

For instance:

xvec = []; yvec = [];
h = plot(xvec, yvec, 'r-'); % Save handle to the line

for i=1:100
get new data point X, Y
xvec = [xvec,X]; % Append to vectors
yvec = [yvec,Y];
set(h, 'xdata', xvec, 'ydata', yvec); % Update plot
drawnow;
end;

I don't have Matlab available right now, so I'm not
completely sure if that call to PLOT will work with
empty vectors. If not, call it after you get your first
data point.

- Randy

From: Rod Gramlich on
I can see how this sill work (i.e. appending a vector)- and I guess
the bottom line is that MATLAB doesn't have any equivalent to 'C'
..... i.e. plot (x,y), follwed by subsequent line_to(x,y) [as you add
points / samples]. I find it peculiar that MATLAB doesn't have such a
capability.

Randy Poe wrote:
>
>
>
> Rod Gramlich wrote:
>> I, as many in here seem to be:), am new to MATLAB. I have
> installed a
>> NI PCI-6036 DAQ. I now have the board working fine, and talking
> to it
>> with MATLAB. My aim is to use the board as a monitor (of a
> voltage
>> level), and then watch for threshold crossings and procede with
> some
>> ao and dio calls. I want to see the data (PLOTTED)in real time
>> (doesn't matter if I miss 'samples'). I'm currently using
>> getsamples(obj), and plotting them fine (but that is only a 1x1
>> matrix). This may sound stupid and naive, but HOW ON GOD'S
EARTH
> DO I
>> JOIN THE DATA POINTS TOGETHER ON THE PLOT (i.e. make a
continuous
>> line ???) ..... note that I'm looping the getsample 100 times
or
> so
>> (i.e. currently plotting 100 points per run) - but can NOT plot
a
>> continuous line. If it's multiple element vectors, then using a
> 'r-'
>> makes a line, but when I'm adding single points one at a time,
I
>> can't get a continuous line. HELP !!
>
> Add each new data point to vectors of x and y components.
>
> For instance:
>
> xvec = []; yvec = [];
> h = plot(xvec, yvec, 'r-'); % Save handle to the line
>
> for i=1:100
> get new data point X, Y
> xvec = [xvec,X]; % Append to vectors
> yvec = [yvec,Y];
> set(h, 'xdata', xvec, 'ydata', yvec); % Update plot
> drawnow;
> end;
>
> I don't have Matlab available right now, so I'm not
> completely sure if that call to PLOT will work with
> empty vectors. If not, call it after you get your first
> data point.
>
> - Randy
>
>
From: Steven Lord on

"Rod Gramlich" <rod.gramlich(a)ualberta.ca> wrote in message
news:eefb0eb.1(a)webx.raydaftYaTP...
>I can see how this sill work (i.e. appending a vector)- and I guess
> the bottom line is that MATLAB doesn't have any equivalent to 'C'
> .... i.e. plot (x,y), follwed by subsequent line_to(x,y) [as you add
> points / samples]. I find it peculiar that MATLAB doesn't have such a
> capability.

Take a look at this (very rough) code:


function line_to(h, x, y)
% Add a data point (x, y) at the end of the line whose handle is h
xdata = get(h, 'XData');
ydata = get(h, 'YData');
set(h, 'XData', [xdata x]);
set(h, 'YData', [ydata y]);


Feel free to expand upon this and add whatever sort of error checking you
want to it.

--
Steve Lord
slord(a)mathworks.com


From: Steve Amphlett on
Rod Gramlich wrote:
>
>
> I can see how this sill work (i.e. appending a vector)- and I guess
> the bottom line is that MATLAB doesn't have any equivalent to 'C'
> .... i.e. plot (x,y), follwed by subsequent line_to(x,y) [as you
> add
> points / samples]. I find it peculiar that MATLAB doesn't have such
> a
> capability.

Uh? What version of 'C' are you using? I don't recall any functions
like that in any of the ANSI standards.
 |  Next  |  Last
Pages: 1 2
Prev: where to find libmatlb.h?
Next: Reading AVI files.