BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / matlab / #5547同步于 2009/5/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Matlab机器人发帖

[求助]小妹求助!关于用,MATLAB求功率谱密度的问题!

lotuswenwen
2009/5/21镜像同步9 回复
我先前用的是 plot(f,abs(fftshift(m)));grid F=abs(fftshift(m)); F=fftshift(m); 怎么折腾这个图就是不出来,还请各位帮忙解决一下,谢谢大家了@!@[em22]
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
dazzlezhang机器人#1 · 2009/5/21
你到底想干什么?m是什么?是FFT的结果吗?
ltx1215机器人#2 · 2009/5/21
【 在 lotuswenwen 的大作中提到: 】 : 我先前用的是 : [color=#1E90FF]plot(f,abs(fftshift(m)));grid : F=abs(fftshift(m)); : ................... 你的命令看上去很乱
lotuswenwen机器人#3 · 2009/5/22
恩恩,我把我想要的发到你的邮箱里呢。 很简单我不知道怎么用MATLAB把功率谱密度这个东西求出来 谢谢你了哦~ 【 在 dazzlezhang 的大作中提到: 】 : 你到底想干什么?m是什么?是FFT的结果吗? [em21]
lotuswenwen机器人#4 · 2009/5/22
恩恩,你也发现啦,原来写这个的时候脑子就比较乱,后来改了一下,在你邮箱里,能帮忙看下吗? 【 在 ltx1215 的大作中提到: 】 : 你的命令看上去很乱 谢谢哦~[em21]
ltx1215机器人#5 · 2009/5/23
【 在 lotuswenwen 的大作中提到: 】 : 我先前用的是 : [color=#1E90FF]plot(f,abs(fftshift(m)));grid : F=abs(fftshift(m)); : ................... 附件(2.9MB) clear clf t0=100; %定义信号持续时间 ts=0.01; %定义仿真时的信号采样率 t=[0:ts:t0]; %定义时间矢量 f1=5; f2=2.5; fc=120; %载波频率w A=sqrt(2); %定义直流偏量 B=sqrt(2); m1 = A*cos(2*pi*f1*t); m2 = B*sin(2*pi*f2*t); subplot(4,2,1) plot(t,m1);grid xlabel('时间t');ylabel('幅度'); title('余弦信号'); axis([0 3 -2 2]) subplot(4,2,2) plot(t,m2);grid xlabel('时间t');ylabel('幅度'); title('正弦信号'); axis([0 3 -2 2]) %m(t)调制信号 m=m1+m2; subplot(4,2,3) plot(t,m);grid xlabel('时间t');ylabel('幅度'); title('调制信号'); axis([0 3 -4 4]) C=2; %定义载波幅度 c=C*cos(2*pi*fc*t); subplot(4,2,4) plot(t,c);grid xlabel('时间t');ylabel('幅度'); title('载波信号'); axis([0 1 -2 2]) %求调制信号的功率谱密度 subplot(4,2,5) fs=1000; %fs为地函数的取样频率 [cory,lag]=xcorr(m,'unbiased'); %其中,m为原函数,cory为要求的自相关函数,lag为自相关函数的长度 plot(lag/fs,cory);title('自相关函数'); xlabel('自相关函数长度与采样率之比'); ylabel('自相关函数'); nfft=1024; CXk=fft(cory,nfft); %求傅里叶变换 Pxx=abs(CXk); index=0:round(nfft/2-1); k=index*fs/nfft; plot_Pxx=10*log10(Pxx(index+1)); subplot(4,2,6) plot(k,plot_Pxx);title('功率谱密度') 你原先里面的f=f=[0:1/ts:1/t0]; 貌似没什么用啊; 这是我做的 你看对吗 不对的话 还请多多指教
dazzlezhang机器人#6 · 2009/5/23
clear; f1 = 5; % frequency of the 1st tone, in Hertz f2 = 2.5; % frequency of 2nd tone, in Hertz fc = 120; % carrier frequency, in Hertz t0 = 100; % holding time, in second ts = 1 / ( 16 * max( [ f1, f2, fc ] ) ); % sampling interval, in second t = 0 : ts : t0; % sampling time sequence % f = 0 : 1/ts : 1/t0; A = sqrt(2); % amplitude of the 1st tone B = sqrt(2); % amplitude of the 2nd tone m1 = A*cos(2*pi*f1*t); % 1st tone m2 = B*sin(2*pi*f2*t); % 2nd tone subplot( 3, 2, 1) % plot the 1st tone plot( t, m1 ); grid xlabel( 'Time [s]' ); ylabel( 'Amplitude' ); title( '1st tone, a cosine wave' ); axis( [ 0 3 -2 2 ] ) subplot( 3, 2, 2 ) % plot the 2nd tone plot( t, m2 ); grid xlabel( 'Time [s]' );ylabel( 'Amplitude' ); title( '2nd tone, a sine wave' ); axis([0 3 -2 2]) % m(t) m = m1 + m2; subplot( 3, 2, 3 ) plot( t, m ); grid xlabel( 'Time [s]' ); ylabel( 'Amplitude' ); title( 'Modulating signal' ); axis( [ 0 3 -4 4 ] ) C=2; % amplitude of carrier c=C*cos(2*pi*fc*t); % plot carrier subplot(3,2,4) plot(t,c);grid xlabel('Time [s]');ylabel('Amplitude'); title('Carrier'); axis([0 0.1 -2 2]) % PSD of the modulating signal subplot(3,2,5) fs = 16 * max( [ f1, f2 ] ); ts = 1 / fs; % sampling interval, in second t = 0 : ts : t0; % sampling time sequence m1 = A*cos(2*pi*f1*t); % 1st tone m2 = B*sin(2*pi*f2*t); % 2nd tone m = m1 + m2; [cory, lag] = xcorr(m,'unbiased'); % unbiased autocorrelation of modulating signal lag = lag / fs; idx = abs( lag ) < 1.5; plot( lag( idx ), cory( idx ) ); % plot autocorrelation of modulating signal xlabel( 'lag [s]' ); ylabel( 'ACF' ); title( 'Autocorrelation of modulating signal' ); fc = fft( cory ) / sqrt( length( cory ) )^2; cm = abs( fftshift( fc ) ); f3= ( - length( fc ) / 2 + 1 : length( fc ) / 2 )' * fs / length( fc ); idx = abs( f3 ) < 6; subplot( 3, 2, 6 ) stem(f3( idx ),cm( idx ), '.' );grid %自相关函数的傅里叶变换:即功率谱密度。其中。cm是cory付里叶变换后的幅值。f3为fc的长度。 xlabel('Frequency [Hz]'); ylabel('Power'); title('PSD of modulating signal'); 【 在 lotuswenwen 的大作中提到: 】 : 恩恩,我把我想要的发到你的邮箱里呢。 : 很简单我不知道怎么用MATLAB把功率谱密度这个东西求出来 : 谢谢你了哦~ : ...................
dazzlezhang机器人#7 · 2009/5/23
功率没搞对 【 在 ltx1215 的大作中提到: 】 : : clear : clf : ...................
ltx1215机器人#8 · 2009/5/23
【 在 dazzlezhang 的大作中提到: 】 : 功率没搞对 恩 谢谢!
Mrkkk机器人#9 · 2009/5/23
【 在 lotuswenwen 的大作中提到: 】 : 我先前用的是 : [color=#1E90FF]plot(f,abs(fftshift(m)));grid : F=abs(fftshift(m)); : ................... 你邮箱发不了了。你有什么算法程序么?