Skip to content

Instantly share code, notes, and snippets.

@sritasngh
Created July 19, 2020 13:52
Show Gist options
  • Save sritasngh/ffd5130e06f008d11086a46672c195fa to your computer and use it in GitHub Desktop.
Save sritasngh/ffd5130e06f008d11086a46672c195fa to your computer and use it in GitHub Desktop.
Write a code in MATLAB to obtain Hilbert transform of the signal x(t)=5 cos(2 π 300t), obtain the analytic signal and plot its amplitude with time, and phase with time.
%Hilbert function
F = 10000; %sampling frequency(Hz)
t = 0:1/F:0.05; %time vector
x= 5*cos(2*pi*300*t); %given signal
x_h=hilbert(x); % Hilbert function of x(t)
figure(1);
plot(t,real(x_h),t,imag(y));
%Plot real and imaginary part of Hilbert function
xlabel('t(sec)'); ylabel('X_h(t)');
legend('real','imaginary');
title('Hilbert Function');
figure(2);
plot(t,abs(x_h));% plot absolute value of Hilbert function
title('Magnitude Vs Time');
figure(3);
plot(t,angle(x_h));% plot angle of Hilbert function
title('Phase Vs Time');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment