Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data1 =[0,1,0]
- function CPkeying(data ,fzero ,fone)
- if(fone >fzero)
- fs = 10* fone;
- else
- fs = 10 * fzero
- endif
- Ts = 1/fs;
- for i = 1:size(data,2)
- if(data(i) == 0)
- f(i) = fzero;
- else
- f(i) = fone;
- endif
- endfor
- for k = 1:size(data,2)
- if(f(k) == fzero)
- samples(end+1:end+fs) = fzero;
- endif
- if(f(k) == fone)
- samples(end+1:end+fs) = fone;
- endif
- endfor
- L = size(samples,2) - Ts;
- t1 = 0:Ts:(L/fs);
- signal = sin(2*pi*samples.*t1);
- N = length(signal);
- X_mags = abs(fftshift(fft(signal)));
- bin_vals = [0 : N-1];
- N_2 = ceil(N/2);
- fax_Hz = (bin_vals-N_2)*fs/N;
- figure(1)
- subplot(2,1,1)
- plot(fax_Hz, X_mags)
- xlabel('Frekvence (Hz)')
- ylabel('Rozsah');
- title('Frekvenční spektrum');
- axis tight
- subplot(2,1,2)
- plot(t1,signal)
- xlabel('Čas')
- ylabel('Amplituda');
- title('Časová oblast');
- axis tight
- endfunction
- CPkeying(data1,2,5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement