How to find peaks of the given signal and find the phase shift with respect to the Oscillator 1 signal?

4 次查看(过去 30 天)
I have this set of 8 signals, I am trying to find the peaks of each signal with respect to time and also I want to find the phase shift of Oscillator 2 to Oscillator 8 with respect to Oscillator 1 signal. Thanks in advance.
I have also attached the Data.mat file.

回答(1 个)

Bjorn Gustavsson
Bjorn Gustavsson 2020-6-29
If you had regularly sampled data (it doesn't seem so) this would best be done with spectrogram. That would give you the spectrogram of the function (i.e. the short-time-Fourier-transform). From that you should take the angle of the fundamental component as the phase-shift between the signals. In principal you could do it with the regular fft as well, but your signal seems to be a bit varying with time.
However, you might have to address the time-variation of your sampling first.
Otherwise this is how I'd do it:
[S1,F1,T1] = spectrogram(data(2,:),hanning(1024),216,[],Fs);
[S2,F2,T2] = spectrogram(data(3,:),hanning(1024),216,[],Fs);
subplot(3,1,1)
pcolor(T1,F1,log10(abs(S1))),shading flat
subplot(3,1,2)
pcolor(T2,F2,log10(abs(S2))),shading flat
subplot(3,1,2)
pcolor(T1,F1,angle(S1.*conj(S2))),shading flat
From that you'd have to start to identify the fundamental frequency of your signals, and then take the corresponding phase-shift.
HTH
  2 个评论
Jay Vaidya
Jay Vaidya 2020-6-29
Okay let me try this. Though, just to tell you that I do have the FFT data of all these signals. These are the signals generated by a electronic simulator and I got the FFT data of these signals too. I can change the time duration for which I want the FFT data too. Below is the FFT data snapshot. Can I use it by any means? It gives the fundamental frequency and the harmonics
This is the new time domain data and the figure. Data file is attached too.
Bjorn Gustavsson
Bjorn Gustavsson 2020-7-2
You need to do a couple of things before you get to your answer. First, before you get to any type of Fourier-transforming you need to look at your sample-times (I'll have to assume that is the first row of your data):
figure
subplot(3,1,1)
plot(data(1,:))
subplot(3,1,3)
hist(data(1,:),200)
hist(diff(data(1,:)),200)
hist(diff(data(1,:)),100)
hist(diff(data(1,:)),200)
subplot(3,1,2)
plot(diff(data(1,:)))
plot(diff(data(1,:)),'.')
So there you see that you have unevenly sample-intervalls. That's one task to resolve.
Then we should have a closer look at the signals (always look at the signal before analysing away):
figure
subplot(2,1,1)
plot(data(1,:),data(2:3,:))
subplot(2,1,2)
plot(data(1,:),data([2,4],:))
If you zoom in on the beginning of these plots, you'll notice that there is an "onset-time" of ~2e-5 time-units. Then you'll see that there is some change of the shift between the signals around 3e-4 - 4.5e-4 time-units.
Since you don't have regularly sampled time-series you cannot use fft-analysis straight off, but since you seem to have sufficiently high sampling rate it should be possible to interpolate your signals to a regular sequence.
t = linspace(data(1,1),data(1,end),2*numel(data(1,:)));
data2 = interp1(data(1,:),data','pchip')';
Then since you have time-varying time-shift between the signals you shouldn't Fourier-transform the entire data-set - that will not give you all information of interest. That's where the short-time-Fourier-transform comes to the rescue, that is the function spectrogram:
clf
Ts = mean(diff(t));
[S1,F1,T1] = spectrogram(data2(2,:),4*1024,1024,[],1/Ts);
[S2,F2,T2] = spectrogram(data2(3,:),4*1024,1024,[],1/Ts);
[S3,F3,T3] = spectrogram(data2(4,:),4*1024,1024,[],1/Ts);
subplot(3,2,1)
pcolor(T1,F1,log10(abs(S2))),shading flat,caxis([-2 3.5]),
ax = axis;
axis([ax(1:2),2e4 5e6])
set(gca,'YScale','log')
colormap(jet)
try
freezeColors
catch
% Useful tool on FEX
end
subplot(3,2,3)
pcolor(T1,F1,log10(abs(S2))),shading flat,caxis([-2 3.5]),
axis([ax(1:2),2e4 5e6])
set(gca,'YScale','log')
try
freezeColors
catch
% Useful tool on FEX
end
subplot(3,2,5)
pcolor(T3,F3,log10(abs(S3))),shading flat,caxis([-2 3.5]),
axis([ax(1:2),2e4 5e6])
set(gca,'YScale','log')
try
freezeColors
catch
% Useful tool on FEX
end
subplot(3,2,2)
pcolor(T3,F3,angle(S1.*conj(S2))),shading flat,caxis([-1 1]*pi),
axis([ax(1:2),2e4 5e6])
set(gca,'YScale','log')
colormap(hsv)
colorbar
subplot(3,2,4)
pcolor(T3,F3,angle(S1.*conj(S3))),shading flat,caxis([-1 1]*pi),
axis([ax(1:2),2e4 5e6])
set(gca,'YScale','log')
colorbar
subplot(3,2,6)
pcolor(T3,F3,angle(S2.*conj(S3))),shading flat,caxis([-1 1]*pi),
axis([ax(1:2),2e4 5e6])
set(gca,'YScale','log')
colorbar
There in the left column you have the PSD of the 2nd 3rtd and 4th rows in data2 and in the right column you have the cross-phases of the 3 combinations. From there you can extract the frequencies of the amplitude-peaks and the corresponding frequency-shifts. As you see the frequencies vary with time, as does the cross-phase between the 1st and second as well as the 2nd and 3rd, from ~0 to ~pi (at around 0.4e-3 time-units).
This is how you find phase-shifts, but since the spectra of your signals varies with time, you should also have a look at the time-shifts between peaks and minimas, both of the signals and their slopes.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by