07-30-2010 06:16 AM
Hi all
I have a simple question. Suppose i have a buffer which has a capacity of 32K samples. If the samples of 1st Sine wave are in the odd positions of the buffer and if the samples of the 2nd sine wave are in the even positions of the same buffer. How can i plot the two sine waves on the same graph accurately. The x-axis is the no. of samples and y-axis the amplitude of sine waves.
Regards
07-30-2010 08:09 AM
Have you looked at the help for PlotWaveform() ? It seems that you can call it twice, using values of 0 and 2 for the initialX and xIncrement parameters on the first call, then using values of 1 and 2 on the second call. With your choice of line styles, colours etc to suit each plot. Haven't tried it myself but it appears to do what you want.
JR
07-30-2010 08:36 AM
Hi JR,
I beg to differ... PlotWaveform uses an array of Y values. For graphic visualization the function needs some information about the horizontal axis, i.e. an offset (initialX) and an incremental value (xIncrement), according to xi = (i × xIncrement) + initialX
I would assume that it is necessary to split the buffer into two.
Wolfgang
07-30-2010 09:06 AM
I stand corrected - there is a similar facility when plotting Stripcharts and being without my CVI system to try it, I assumed there was also one for Graphs. Sorry.
Back to my mid-afternoon coffee!
JR
07-30-2010 09:20 AM
It might be worth a feature request - cloning the function PlotStripChart to a new function PlotYGraph...
07-30-2010 10:40 AM
In any case, splitting an insterleaved array is easy using Decimate () function: Decimating factor must ewual the munber of signals interleaved in input array and Averaging parameter must be 0.
In mhs case these two instructions should be enough to split measures:
Decimate (MeasArray, nSamples * 2, 2, 0, OutArray1);
Decimate (MeasArray + 1, nSamples * 2, 2, 0, OutArray2);
where:
MeasArray is the interleaved array
nSamples is the numer of samples-per-channel
OutArrayX are the output arrays
08-02-2010 06:31 AM
hi JR and Roberto
I am using the plotwaveform but still there is the problem
the odd and even samples are mixing with each other. my statements are
void SetRealBuffer(float far *lpBuf, long num);
void SetRealBuffer(float far *lpBuf, long num)
{
int i, r;
//float magnitude,mem_mag=2;
double offset=0;
//GetCtrlVal(panelHandle,PANEL_POINTS,&points);
//GetCtrlVal(panelHandle,PANEL_AMPLITUDE,&magnitude);
//GetCtrlVal(panelHandle,PANEL_OFFSET,&offset);
for (i = 0; i < num;i+=2)
{
*(lpBuf+i) = (float)( magnitude1
* sin(6.28318*(double)i/2048)
+ offset);
}
PlotWaveform(panelHandle,PANEL_WAVEFORM, (LONG far *)lpBuf,32768,VAL_FLOAT,1,0,1,2,VAL_CONNECTED_POINTS,VAL_SIMPLE_DOT,VAL_SOLID,1,VAL_BLUE);
PlotWaveform(panelHandle,PANEL_WAVEFORM,(LONG far *)lpBuf,32768,VAL_FLOAT,1,0,0,2,VAL_CONNECTED_POINTS,VAL_SIMPLE_DOT,VAL_SOLID,1,VAL_RED );
I also use the decimate function but it didnt work , plz reply
08-02-2010 08:45 AM
As Wolfgang pointed out, my suggestion to try to use initialx to separate the data points was incorrect. The Decimate() function recommended by Roberto requires double data types, whereas your code uses floats. Perhaps you could try again using matching data types and if it still doesn't work post the code that uses the Decimate() function.
JR