資源簡介
繪制隨機相位正弦波相關數字特性
代碼片段和文件信息
clearclc
%初始化
fs=100;???????????????????????%采樣頻率100
t=0:1/fs:pi;??????????????????%設置時間范圍0~pi
B=0;??????????????????????????%設置初始相位為0
A=1;??????????????????????????%信號的幅度為1
f=10;?????????????????????????%信號頻率為10Hz
%畫隨機相位正弦波
B=2*pi*rand(1length(t));?????%求變化范圍是0~2pi的隨機相位
x=A.*sin(2*pi*f.*t+B);
e1=mean(x)????????????????????%計算均值
s1=var(x)?????????????????????%計算方差?
[rlags]=xcorr(x);????????????%計算自相關函數???
subplot(411)
plot(tx)
title(‘隨機相位正弦波‘);xlabel(‘t‘);ylabel(‘幅值x‘);
subplot(412)
plot(te1)
title(‘均值‘);xlabel(‘t‘);ylabel(‘e‘);
subplot(413)
plot(ts1)axis([03.14-0.20.2])
title(‘方差‘);xlabel(‘t‘);ylabel(‘s‘);
subplot(414)
plot(lags/fsr)axis([03.1401])
title(‘自相關函數‘);xlabel(‘時間間隔‘);ylabel(‘r‘);
%幅度,相位,頻率還原初始化情況
A=1;??????????????????????????%信號的幅度為1
B=0;??????????????????????????%設置初始相位為0
f=10;?????????????????????????%信號頻率為10Hz
%畫幅度隨機正弦波
A=raylrnd(1:length(t));???????%產生滿足瑞利分布的隨機幅度
x=A.*sin(2*pi*f*t+B);?
e2=mean(x)????????????????????%計算均值
s2=var(x)?????????????????????%計算方差?
[rlags]=xcorr(x);????????????%計算自相關函數???
figure
subplot(411)
plot(tx)
title(‘隨機幅度正弦波‘);xlabel(‘t‘);ylabel(‘幅值x‘);
subplot(412)
plot(te2)
title(‘均值‘);xlabel(‘t‘);ylabel(‘e‘);
subplot(413)
plot(ts2)
title(‘方差‘);xlabel(‘t‘);ylabel(‘s‘);
subplot(414)
plot(lags/fsr)
title(‘自相關函數‘);xlabel(‘時間間隔‘);ylabel(‘r‘);
%幅度,相位,頻率還原初始化情況
A=1;??????????????????????????%信號的幅度為1
B=0;??????????????????????????%設置初始相位為0
f=10;?????????????????????????%信號頻率為10Hz
%畫隨機頻率正弦波
f=20*rand(1length(t));???????%產生均勻分布的隨機頻率,以10Hz為中心,上下寬度10Hz
x=A.*sin(2*pi*f.*t+B);
e3=mean(x)????????????????????%計算均值
s3=var(x)?????????????????????%計算方差?
[rlags]=xcorr(x);????????????%計算自相關函數???
figure
subplot(411)
plot(tx)
title(‘隨機頻率正弦波‘);xlabel(‘t‘);ylabel(‘幅值x‘);
subplot(412)
plot(te3)
title(‘均值‘);xlabel(‘t‘);ylabel(‘e‘);
subplot(413)
plot(ts3)
title(‘方差‘);xlabel(‘t‘);ylabel(‘s‘);
subplot(414)
plot(lags/fsr)
title(‘自相關函數‘);xlabel(‘時間間隔‘);ylabel(‘r‘);
%幅度,相位,頻率還原初始化情況
A=1;??????????????????????????%信號的幅度為1
B=0;??????????????????????????%設置初始相位為0
f=10;?????????????????????????%信號頻率為10Hz
%畫隨機相位頻率正弦波
B=2*pi*rand(1length(t));?????%產生0~2pi均勻分布的隨機相位
f=20*rand(1length(t));???????%產生均勻分布的隨機頻率,以10Hz為中心,上下寬度10Hz
x=A*sin(2*pi*f.*t+B);
e4=mean(x)????????????????????%計算均值
s4=var(x)?????????????????????%計算方差?
[rlags]=xcorr(x);????????????%計算自相
- 上一篇:風力機模型的仿真
- 下一篇:matlab 圖像加噪去噪
評論
共有 條評論