How to determine phase shift and slope for a varying waveform?
Mostrar comentarios más antiguos
Hi,
I have 12 nos. of probes which detects and picks signals (namely obp1n to obp12n). After determining the spectogram and filtering the waveform, I want to keep obp1n as my reference probe and determine phase shift of signals from others with reference to obp1n and hence determine the slope.
Now, the problem is the amplitudes of these waveforms are varying from one probe to another, also they are shifting horizontally (along time axis). Thus I'm not getting the proper determination of phase shift.
I'm not getting the correct value for phase shift and hence slope.
Kindly advice.
rgds,
rc
f = @(filename) fullfile('D:\Data_tokamak\TT1 data',filename );
file = f('OBP6N.txt');
%filecontents = fileread('OBP1N.txt'); % Check File Format & Contents
data = readmatrix(file, 'HeaderLines',8); % Skip First 8 Header Lines
data(:,1) = data(:,1) * 1E-3; % Time in milliseconds
nonfinite_rows = nnz(~any(isfinite(data),2)); % Check To See If Any Rows Have Non-Finite Values
if nonfinite_rows > 0
data(~isfinite(data)) = NaN;
data = fillmissing(data, 'linear');
end
x_data = data(:,1);
y_data = data(:,2);
Ts = mean(diff(x_data));
Tsd = std(diff(x_data));
Fs = 1/Ts;
[y_data,x_data] = resample(y_data, x_data, round(Fs)); % Resample To Constant Sampling Frequency
Fs = round(Fs);
Fn = Fs/2;
figure(1)
pspectrum(y_data, Fs, 'spectrogram'); % Plot 'pspectrum' 'spectrogram'
colormap(turbo); % Introduced: R2020b
[sp,fp,tp] = pspectrum(y_data,Fs,"spectrogram"); % Return Values, Then Plot
figure(2)
waterfall(fp,tp,sp');
set(gca,XDir="reverse",View=[60 60]);
colormap(turbo); % Introduced: R2020b
ylabel("Time (s)");
xlabel("Frequency (Hz)");
figure(3)
waterfall(fp,tp,sp');
set(gca,XDir="reverse",View=[60 60]);
Ax = gca;
Ax.ZScale = 'log';
colormap(turbo); % Introduced: R2020b
ylabel("Time (s)");
xlabel("Frequency (Hz)");
% Design filter for studying activities at particular frequency
wp = [39.5 40.5]/Fn; % Passband frequency Normalized
ws = [0.98 1.02].*wp; % Stopband frequency Normalized
Rp = 1; % Passband Ripple
Rs = 60; % Passband Ripple (Attenuation)
[n,wp] = ellipord(wp,ws,Rp,Rs); % Elliptic order calculation
[z,p,k] = ellip(n,Rp,Rs,wp); % Elliptic filter design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second order selection for stability
figure(4)
freqz(sos, 2^18,Fs) ; % Filter Bode Plot
set(subplot(2,1,1), 'XLim',[0 100]) % OPTTIONAL
set(subplot(2,1,2), 'XLim',[0 100]) % OPTTIONAL
[h w] = freqz(sos, 2^18,Fs) ;
%Implementation of filtfilt function
y_data_filt = filtfilt(sos, g, y_data); % Filter Signal
figure(5)
yyaxis right
plot(x_data, y_data_filt,'.')
grid
xlabel('Time')
ylabel('Amplitude')
hold on
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Get Started with Signal Processing Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



