10-08-2008 07:30 PM
I have a 1D array and generate a signal using building waveform with dt of 2e-8. I picked some elements from the array which is not even spaced (the indexes are 1,4,8,9,13......) and built a new array, I know the time array which is corresponded to the new array , how to use the new array and new time array to generate another signal?
10-08-2008 08:16 PM
What are you going to do with this new signal? Is it just for display on the front panel or are you planning on outputing this through a DAQ card?
Assuming it is just for display, you could take your array of indices and multiply by your dt. This would be your X array for sending to an XY graph along with your built array of the Y values.
If you are going to send to a DAQ card, you are going to need to maintain a waveform where the data points are evenly spaced to match the output rate of the card. Then the question is to you want to maintain a steady signal for the period of time between 1 indice and the next. Or do you want the missing indices to be a linear interpretation between the known points.
Let's say you have 0,4,5,9 as 0,1,2,3, do you want it to remain 0 volts from time 0 to 4, then jump to 1 at time 4, 2 at time 5, and hold steady until it jumps to 3 at time9. Or have it linearly increase from 0 to 1 between time 0 and 4.
Whatever you do, you will have to maintain you large array with evenly spaced time elements anf fill the elements between you known indices as necessary.
10-08-2008 09:56 PM
Thank you for your reply!
Actually I am using the new signal to resample another signal. Let me describe the whole thing that I am trying to do. I aquired two signals A and B. Each array contains 2500 points and dt is 2e-8s. I need to resample signal A at the locations same as peaks and valleys locations in signal B. Then I need to compare the FFT of signal A and resampled signal A. I used peak detector.vi to pick the peaks and valleys and concatenate them and sort them. The problem is that peak detector find the interpolated index location, but I need the exact index number. I don't know how to fix it.
Then I need to resample A. I tried to use index A at the index of peaks and valleys of B and rebuild them to another array. But the result is not as good as Matlab (I mean FFT of resampled A is not so sharp). And for loop will slow down the program. Then I found align and resample.vi. I tried to use the new signal from peaks and valleys of B as the reference signal. A as a signal input. But I don't know how to generate the uneven spaced signal from peaks and valleys of signal B.
10-09-2008 08:05 AM
I am not sure I completely understand your intention. Do you want to calculate an FFT for the elements of A which occur at the peaks and Valleys of B?
If so, I would create an array A' which contains all zeros and then use Replace Array Subset to replace the elements of A' with the corresponding elements of A at the maxima and minima of B. Then the FFT of A' could be compared to the FFT of A or B. Since all the arrays are of the same length and the same dt the FFTs would all have the same df. Just convert the interpolated indexes from the peak detector to integers. Those should be the nearest indexes to the peak.
However, the A' array will consist of a set of varying amplitude impulses and so its FFT will consist of superimposed sine(x)/x patterns. I do not see how this would be a meaningful analysis of your data.
What is it that you want to learn about the data in A?
Lynn
10-09-2008 10:29 AM
10-09-2008 11:29 AM
I understood that part about A being unevenly sampled. The procedure I suggested will produce an array of evenly sampled data with the same dt as the original.
I have not used or looked at the Align and Resample.vi so I cannot say. Did you look at the help?
Lynn