Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- clear all
- close all
- %vm = input('Enter Amplitude (Message) = ');
- %vc = input('Enter Amplitude (Carrier) = ');
- %fM = input('Enter Message frequency = ');
- %fC = input('Enter Carrier frequency = ');
- %m = input('Enter Modulation Index = ');
- message =[...
- 0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 0...
- 0 1 0 0 0 0 0 0 1 0 1 0 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 1 0 1 1 0 0 0 1...
- 1 0 0 1 0 0 0 0 1 0 0 0 0 1];
- t = [0:1/(100*fC):10/fM]; %10000 samples
- msg = vm*cos(2*pi*fM*t);
- subplot(4,1,1);
- plot(t,msg); %plotting message signal
- refresh;
- xlabel('Time [s]');
- ylabel('Amplitude [V]');
- title('Message Signal waveform');
- grid on;
- axis tight
- carrier = vc*sin(2*pi*fC*t);
- subplot(4,1,2);
- plot(t,carrier); %plotting carrier signal
- xlabel('Time [s]');
- ylabel('Amplitude [V]');
- title('Carrier Signal waveform');
- grid on;
- axis tight
- y = vc*cos(2*pi*fC*t+m*sin(2*pi*fM*t));
- subplot(4,1,3);
- plot(t,y); %plotting FM (Frequency Modulated) signal
- xlabel('Time [s]');
- ylabel('Amplitude [V]');
- title('FM Signal waveform');
- grid on;
- axis tight
- N = length(y);
- fs = 100*fC; %50 mega samples per second
- fnyquist = fs/2; %Nyquist frequency
- X_mags = abs(fftshift(fft(y)));
- bin_vals = [0 : N-1];
- N_2 = ceil(N/2);
- fax_Hz = (bin_vals-N_2)*fs/N;
- subplot (4,1,4);
- plot(fax_Hz(N_2:52000), X_mags(N_2:52000), '-r', 'LineWidth', 2 )
- xlabel('Frequency [Hz]')
- ylabel('Magnitude');
- title('Double-sided Magnitude spectrum (Hertz)');
- grid on
- axis tight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement