plot aprove fourier transform property in matlab

To plot and verify the Fourier Transform properties in MATLAB, you can follow these steps:

  1. Generate a test signal. Let's use a simple sine wave as an example:
main.m
fs = 1000; % sampling frequency
t = 0:(1/fs):1; % time vector
f = 10; % frequency of the sine wave
x = sin(2*pi*f*t); % sine wave signal
137 chars
5 lines
  1. Compute the Fourier Transform of the signal using the fft function:
main.m
X = fft(x);
12 chars
2 lines
  1. Plot the magnitude spectrum of the Fourier Transform:
main.m
frequencies = 0:(fs/length(x)):(fs-(1/fs));
magnitude_spectrum = abs(X);
plot(frequencies, magnitude_spectrum);
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('Magnitude Spectrum');
grid on;
197 chars
8 lines
  1. Verify the Fourier Transform properties. Here are a few examples:
  • Linearity:

    main.m
    a = 2; % scaling factor
    y1 = a * x; % scaled signal
    Y1 = fft(y1); % Fourier Transform of the scaled signal
    
    y2 = 3 * x; % another scaled signal
    Y2 = fft(y2); % Fourier Transform of the other scaled signal
    
    % Verify linearity property
    is_linearity_preserved = isequal(a * X, Y1) && isequal(3 * X, Y2);
    disp(is_linearity_preserved);
    
    331 chars
    11 lines
  • Time Shift:

    main.m
    t_shift = 0.3; % time shift value
    x_shifted = sin(2 * pi * f * (t - t_shift)); % time-shifted signal
    X_shifted = fft(x_shifted); % Fourier Transform of the time-shifted signal
    
    % Verify time shift property
    is_time_shift_preserved = isequal(X_shifted, exp(-1i * 2 * pi * f * t_shift) * X);
    disp(is_time_shift_preserved);
    
    320 chars
    8 lines
  • Frequency Shift:

    main.m
    f_shift = 5; % frequency shift value
    x_shifted_freq = sin(2 * pi * (f + f_shift) * t); % frequency-shifted signal
    X_shifted_freq = fft(x_shifted_freq); % Fourier Transform of the frequency-shifted signal
    
    % Verify frequency shift property
    is_frequency_shift_preserved = isequal(X_shifted_freq, X.* exp(1i * 2 * pi * f_shift * t));
    disp(is_frequency_shift_preserved);
    
    367 chars
    8 lines
  • Convolution:

    main.m
    impulse_response = [1, 0.5, 0.2, 0.1]; % example impulse response
    y_conv = conv(x, impulse_response); % convolution of the input signal and impulse response
    Y_conv = fft(y_conv); % Fourier Transform of the convolved signal
    
    impulse_response_FT = fft(impulse_response); % Fourier Transform of the impulse response
    
    % Verify convolution property
    is_convolution_preserved = isequal(Y_conv, X .* impulse_response_FT);
    disp(is_convolution_preserved);
    
    446 chars
    10 lines

These are just a few examples of how you can plot and verify Fourier Transform properties in MATLAB.

related categories

gistlibby LogSnag