Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc, close all, clear all
- %%Zadanie 1
- %Data
- fs = 5000; %Sample freq
- fm = 1; %1
- fc = 100; %Carrier freq
- Am = 1;
- Ac = 0.5;
- kf = 20;
- b = (kf*Ac)/fm;
- t = 0:1/fs:((4/fm)-(1/fs));
- %Modulated signal
- msignal = Am*cos(2*pi*fm*t);
- c_msignal = cumsum(msignal)/fs;
- msignal2 = square(2*pi*fm*t)*(1.5/2)+0.15;
- c_msignal2 = cumsum(msignal2)/fs;
- xfm = cos(2*pi*fc*t).*cos(2*pi*b*c_msignal)-sin(2*pi*fc*t).*sin(2*pi*b*c_msignal);
- xfm2 = cos(2*pi*fc*t).*cos(2*pi*b*c_msignal2)-sin(2*pi*fc*t).*sin(2*pi*b*c_msignal2);
- xfm_func = fmmod(msignal,fc,fs,b);
- xfm_func2 = fmmod(msignal2,fc,fs,b);
- %Spectres
- NoOfProbes = 2^nextpow2( length(xfm) );
- xfm_spec = 20*log10(abs(fft(xfm,NoOfProbes)/NoOfProbes));
- xfm_spec2 = 20*log10(abs(fft(xfm2,NoOfProbes)/NoOfProbes));
- f_w_b=fs/2*linspace(-1,1,NoOfProbes);
- %Modulation (1st - sin signal)
- figure(1)
- subplot(4,1,1);
- plot(msignal);grid;
- title('Message signal');
- %xlim([20000 100000]);
- subplot(4,1,2);
- plot(xfm);grid;
- title('Modulated signal');
- %xlim([20000 100000]);
- subplot(4,1,3);
- plot(xfm_func);grid
- title('Modulated signal with fmmod function');
- %xlim([20000 100000]);
- subplot(4,1,4);
- plot(f_w_b,[xfm_spec(NoOfProbes/2+2:end), xfm_spec(1:NoOfProbes/2+1)]);grid
- title('Spectre of modulated sin signal');
- ylabel('FFT [dB]','FontSize',12);
- %Modulation (2nd - square signal)
- figure(2)
- subplot(4,1,1);
- plot(msignal2);grid;
- title('Message signal');
- %xlim([20000 100000]);
- subplot(4,1,2);
- plot(xfm2);grid;
- title('Modulated signal');
- %xlim([20000 100000]);
- subplot(4,1,3);
- plot(xfm_func2);grid
- title('Modulated signal with fmmod function');
- %xlim([20000 100000]);
- subplot(4,1,4);
- plot(f_w_b,[xfm_spec2(NoOfProbes/2+2:end),xfm_spec2(1:NoOfProbes/2+1)]);grid
- title('Spectre of modulated square signal');
- xlabel('f [Hz]','FontSize',12);
- ylabel('FFT [dB]','FontSize',12);
- msignalPower = rms(msignal)*rms(msignal)
- c_msignalPower = rms(c_msignal)*rms(c_msignal)
- xfmPower = rms(xfm)*rms(xfm)
- xfm2Power = rms(xfm2)*rms(xfm2)
- s = hilbert(xfm).*exp(sqrt(-1)*2*pi*fc*t);
- figure;
- plot(s)
- Z = fmdemod(xfm,fc,fs,b);
- %Waskopasmowa - b musi byc male
- %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement