# How can I separate measurement data at different frequencies?

Asked by mel on 18 Aug 2012
Latest activity Commented on by Azzi Abdelmalek on 24 Aug 2012

hi,

I have measured strain at different stresses (50 V, 150 V, 250 V, 500 V, 1000 V) and frequencies(0.5 Hz, 1 Hz, 10 Hz, 100 Hz, 200 Hz). Moreover I have the data of these stresses (sinus-curves with 10 cycles) at the different frequencies along measurement time.

How can I separate the areas of different frequencies, to plot stresses over strain?

The plot of different stresses at different frequencies looks like: after a short time (start of the program) it starts with a sinus-curve with the first frequency 0.5 Hz and amplitude 50 V, then it takes a break of a few seconds, and after that starts with second frequency 150 V at the same amplitude, and so on, until it starts with next amplitude 150 V for again all frequencies.

Image Analyst on 19 Aug 2012

I don't understand the last sentence. It seems to contradict the first sentence. Are your amplitudes for the 1, 10, 100, and 200 Hz sine waves all 150 Volts (like the last sentence says), or are they 150 V, 250 V, 500 V, 1000 V like the first sentence says?

Azzi Abdelmalek on 19 Aug 2012

i think hi made an error when he said 150v (he meant 50v) with all frequencies, then the same is reproduced for 150V, 250V,...

Image Analyst on 19 Aug 2012

Oh, so it's every possible combination? Could be. I thought it was that they were paired up 50V @ 0.5 Hz, 150V @ 1 Hz, 250 V at 10 Hz, and so on. I wonder if we'll ever hear from mel again, or are we just wasting our time?

## Products

No products are associated with this question.

Answer by Image Analyst on 18 Aug 2012
Edited by Image Analyst on 18 Aug 2012

A diagram or plot would sure help. It actually sounds very trivial if you have the Image Processing Toolbox. Do you have that? Just use thresholding, labeling, and regionprops to identify the quiet or still sections that divide your sine waves, then split it up.

Or you could use find:

```startingElement = find(signal>=someVoltageValue, 1, 'first');
lastElement = find(signal>=someVoltageValue, 1, 'last');
```

to find the first and last place where a certain voltage happens. Though with that, you have to make sure you go down from the peak to the baseline to make sure you get the whole half-cycle of the sine wave and not just start at the peak.

If you can supply a vector of values with the different signal values, I could demonstrate.

Azzi Abdelmalek on 18 Aug 2012

is your sample time fixed? if yes what is it? are your amplitudes and frequency known?

Image Analyst on 18 Aug 2012

That's what I wondered at first but then I saw that she had exactly 10 cycles for each sample at a particular frequency. Since the sine waves are different frequencies (periods), the sample times for each of the five 10-cycle samples will all be different. However I would think that the sample rate would be the same.

For example, if the sample rate is 1 Khz, 10 cycles of a 0.5 hz signal would be 20 seconds for that sample and at 1000 samples per second, that would be 20,000 samples for the 0.5 Hz sample.

Ten cycles of the 200 Hz would be 10*(1/200) seconds or 0.05 seconds for that sample. Then multiply by 1000 samples /sec and you get 50 samples for the 200 Hz sample.

mel on 19 Aug 2012

Hi, i have the image processing toolboox. to supply a vector is very difficult, because i measured all 0.0002 seconds, so that are a lot of data.

but i try to explain better: first data show sine wave with amplitude 50V and frequency of 0.5Hz for 10 cycles(takes 20seconds), then comes the break of a few seconds(so u can see at plot what time starts the next one), the next sine wave with amplitude 50V but a frequency of 1Hz(takes 10seconds), same break, amplitude 50V and Frequency 10Hz(takes 1second), break, amplitude 50V and frequency 100Hz(0.1second), break, amplitude 50V and frequency 200Hz(0.5seconds), break now i change the amplitude to 150V: next is amplitude 150V and frequency 0,5HZ, break, amplitude 150V and frequency 1Hz, break, amplitude 150V and frequency 10Hz, break, amplitude 150V and frequency 100Hz, break, amplitude 150V and frequency 200HZ; and so on and now i need for all this data everytime that area of one frequency at one amplitude separatly the problem is i don't have a smooth signal, so i have a lot of peaks, and after smoothing there is not only one point with highest value, so i cant't find my peak with the findpeak function i tried a lot, now i think the only which help is that matlab can see the different frequency areas, so that i can get them

Answer by Azzi Abdelmalek on 18 Aug 2012
Edited by Azzi Abdelmalek on 20 Aug 2012

what i suggest is to do some part of the job manualy

```load HV_Piezo1;
y=HV_Piezo1;x=HV_Piezo1_x;plot(y);
[k1,h1]=ginput  % will wait that you click on the graph
% click at every end of your part of signal; in this case:click 16 times
% when you have finished selection click: <return>
```
``` k0=1
for k=1:length(k1)
figure;plot(x(k0:k1(k)),y(k0:k1(k)))
k0=k1(k)
end```

Image Analyst on 19 Aug 2012

Those don't look like 10 cycles in each sine wave burst. Plus, each group looks like it's 50 element long, so why can't you just do

```group1 = signal(1:50);
group2 = signal(51:100);
```

and so on?

Azzi Abdelmalek on 19 Aug 2012

ry the code i ve updated, it allows to select manualy the different point of your signals (the end points )

mel on 20 Aug 2012

Hi, but how i get the data(x,y values) of each area now? And how i can delete the data before my wave starts i need something like that http://imageshack.us/photo/my-images/266/plot2s.jpg/ and the data(x,y) for what is shown. the problem is, i don't know the exact starting time, so with time the plots delay

i write now that code for first 4 waves where i try to find end of every wave and get my starting point for every wave with it:

``` load('HV_Piezo1.mat')
[pks, loks]=findpeaks(HV_Piezo1,'MINPEAKHEIGHT', 100,'NPEAKS',1);
n=Funktionsgenerator_x(loks);
a=[18/0.0002, 33.5/0.0002, 39.95/0.0002, 45.095/0.0002];
h=[2/0.0002, 1/0.0002, 2/20/0.0002, 2/200/0.0002];
g=[20/0.0002, 10/0.0002, 1/0.0002, 0.1/0.0002]
j=0;
v=[20, 10, 1, 0.1];
for i=1:4
for e=loks+a(i):loks+a(i)+h(i)
j=j+1;
f(j)=HV_Piezo1(e);
end
c=find(f==0);
l(i)=c(1)+loks+a(i)-1
y(i)=HV_Piezo1(l(i));
x(i)=HV_Piezo1_x(l(i));
j=0;
w(i)=a(i)
u(i)=l(i)- g(i)
for o=u(i):l(i)
j=j+1;
d(j,i)=HV_Piezo1(o,1);
b(j,i)=HV_Piezo1_x(o,1);
count(i)=j;
end
j=0;
end```

but at i=4 i get that error:Attempted to access HV_Piezo1(247194); index must be a positive integer or logical. Error in sepa3 (line 17) f(j)=HV_Piezo1(e);

i don't understand it, perhaps u can help, thanks a lot

Answer by Azzi Abdelmalek on 20 Aug 2012
Edited by Azzi Abdelmalek on 20 Aug 2012
``` clear
y=HV_Piezo1;x=HV_Piezo1_x;plot(y);
close;plot(y)
test=1,
for k=1:16
test=1
while test==1
pause
[k1,h1]=ginput
choice=questdlg('choose between undo and continue','undo choice','continue','undo','undo')
switch choice
case 'continue'
test=0;
case 'repeat'
test=1;
end
end
k1=int64(k1);
z{k}=[x(k1(1):k1(2)) y(k1(1):k1(2))];```
``` end
for k=1:16
xy=z{k};
x=xy(:,1);y=xy(:,2);
figure;plot(x,y);
end```
1. zoom one part of your signal
2. click any key, because the code is paused
3. select the start point and the end then click "return"
4. now the code is again paused. undo zoom and zoom the next wave. and repeat from 1
5. i 've added a test in case u want repeat one operation note: don't click any key before zooming your wave, because you will not be able to do it if "[k1,h1]=ginput" is executed

mel on 22 Aug 2012

Hi, thanks a lot, i changed it little bit, so that i get all x and y values for every area and i get also data for the other measurements i do at same time.

I still have one question: i have a lot of measurements like that(different piezos and temperature), is there any possibility that matlab see the different frequency areas itself, so that i can write only one script for every separate measurement. Now i have to click my areas for every meassurement myself.

Azzi Abdelmalek on 24 Aug 2012

i tried to do it, but i found it difficult , because your signals are not real sinusoides, because of noises.