-
大小: 3KB文件類(lèi)型: .rar金幣: 2下載: 0 次發(fā)布日期: 2022-06-24
- 語(yǔ)言: Matlab
- 標(biāo)簽:
資源簡(jiǎn)介
基于matlab的信號(hào)頻域的相干分析,希望在不同方向?qū)Υ蠹矣兴鶐椭?img width=510 src=http://www.sh-liguang.com/pic/137890.jpg />
代碼片段和文件信息
%%?分析x與y的相干性?頻域線性相關(guān)性?找到相關(guān)性最強(qiáng)的頻帶及該頻帶的相位差
function?coherence(xy)
n=length(x);
%?nfft?=?2^(nextpow2(n)-1);
nfft=500;
fs=1000;
[cxy1f1]=mscohere(xyhanning(nfft)nfft/2nfftfs);%窗口有50%的重疊
cxy=sqrt(cxy1);
%?figure;
%?plot(f1cxy);
m=(n/(nfft/2))-1;%窗口個(gè)數(shù)
CL=1-0.05^(1/(m-1));
CL=CL*ones(1length(f1));
figure;
plot(f1cxy‘-k‘f1CL‘-r‘);
%?axis([0?50?0?max(c(1:50))]);
%?ylabel(‘S‘);xlabel(‘Hz‘);
%?axis([0?50]);
xlabel(‘f/Hz‘);ylabel(‘coherence‘);
f?=?0:fs/nfft:fs/2;
f?=?f‘;
w?=?hanning(nfft);
z?=?csd(xynfftfswnfft/2);
t=n/fs;
Time?=?0.001:0.001:t;
%繪制兩個(gè)互譜信號(hào)的時(shí)程曲線圖
figure;
subplot(211);
plot(Timex);
xlabel(‘時(shí)間(s)‘);
ylabel(‘幅值‘);
grid?on;
title(‘信號(hào)時(shí)程曲線‘);
subplot(212);
plot(Timey);
xlabel(‘時(shí)間(s)‘);
ylabel(‘幅值‘);
grid?on;
%繪制幅頻曲線圖
[maxvaluemaxindex]?=?max(abs(z));
maxfreq?=?f(maxindex);
phase?=?angle(z(maxindex));
phasedeg?=?rad2deg(phase);
figure;
nn?=?1:nfft/8;
subplot(211);
plot(f(nn)abs(z(nn))‘b-‘20maxvalue‘ro‘);
%axis([0?50]);
xlabel(‘頻率(Hz)‘);
ylabel(‘幅值‘);
textlable=strcat(‘\leftarrow?f=?‘num2str(maxfreq));?????
text(maxfreqmaxvaluetextlable‘Fontsize‘14‘Color‘‘r‘);
grid?on;
title(‘互譜幅頻、相頻曲線‘‘Units‘‘normalized?‘‘Position‘[0.5?1]‘FontSize‘13);
subplot(212);
plot(f(nn)angle(z(nn))‘b-‘maxfreqphase‘ro‘);?%axis([0?50]);
xlabel(‘頻率(Hz)‘);
ylabel(‘相位‘);
textlable=strcat(‘\leftarrow?phase=?‘num2str(phase));?????
text(maxfreqphasetextlable‘Fontsize‘14‘Color‘‘r‘);
grid?on;
disp([‘****???The?phase?between?‘‘c3‘‘?and?‘‘emg‘‘?is:?‘num2str(phasedeg)‘?deg.???****‘]);
timedelay?=?phase/(2*pi*maxfreq);
disp([‘****???The?delaytime?between?‘‘c3‘‘?and?‘‘emg‘‘?is:?‘num2str(timedelay*1000)‘?ms.???****‘]);
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????1830??2013-04-28?15:39??相干\coherence.m
?????文件???????3411??2011-11-29?09:28??相干\myphase.m
?????文件????????320??2013-04-29?19:23??相干\pinpu.m
?????目錄??????????0??2014-12-15?19:50??相干
-----------?---------??----------?-----??----
?????????????????5561????????????????????4
評(píng)論
共有 條評(píng)論