資源簡介
循環(huán)平穩(wěn)信號 MATLAB 仿真 具體額代碼還是不錯的!
代碼片段和文件信息
clear?all;clc;clear;
tic?
%-------------------------signal?generate---------------------------------%
Fs?????????=?5120;
Fc?????????=?200;?%?Carrier?frequency?in?Hz??
t??????????=?[1:512]‘/Fs;?%?Sampling?times?for?.1?second
x??????????=?sin(20*pi*t)‘;?%?Representation?of?the?signal?
y??????????=?ammod(xFcFs);?%?Modulate?x?to?produce?y.
%?figure;
%?subplot(211);?plot(tx);title(‘Representation?of?the?signal‘);?%?Plot?x?on?top.
%?subplot(212);?plot(ty);title(‘Modulate?x?to?produce?y‘);?%?Plot?y?below.
%-------------------------end---------------------------------------------%
%-------------------------add?AWGN-----------------------------------------%
N??????????????=length(y);
y_power????????=var(y);
y??????????????=y/sqrt(y_power);
signalPower????=1;
SNR_dB?????????=5;??
SNR????????????=10^(SNR_dB/10);??
noise_Power????=signalPower/SNR;???%noise?power
noise??????????=sqrt(noise_Power/2)*randn(1N);%AWGN
signal?????????=y+noise;
%-------------------------end---------------------------------------------%
%-------------------------calculate?cyclic?spectal------------------------%
alpha_len??????=(-0.5:1/N:0.5-1/N);
M??????????????=N/64;?%window?length
X??????????????=fft(signal);
X??????????????=fftshift(X);
f??????????????=-Fs/2:Fs/(N-1):Fs/2;
%?plot(fabs(X));
%-------------------------calculate?cyclic?spectal(1/4?cyclic?spectal,need?to?spread)-----------------------------------------%
for?alpha=1:N/2-M/2+1
????for?f1=1:N/2-M/2+2-alpha
????????if?f1==1?
????????????tmp(alphaf1)=X([f1+N/2+alpha-1-M/2:f1+N/2+alpha-2+M/2])*(X
評論
共有 條評論