我想用這樣的時變頻率創建正弦時間序列。我們觀察時間從2.93秒,從0到1秒,我想創建正弦數據加上一組頻率的白噪聲,而從1到2.93秒另一組頻率,爲此我寫了以下代碼生成時變頻率的正弦模型
% non stationary signal with time varying frequency
fs=100 ; % sampling frequency
ts=1/fs;
t=(0:ts:2.93); % time vector
% i want to create signal which consist of sinusoidal components in
% addtiive of white noise , frequencies are defined in time as
x=25*sin(2*pi*23*t(t<1))+20*cos(2*pi*24*t(t<1))+24*sin(2*pi*22*t(t<1))+10*randn(size(t));
y=21*sin(2*pi*20*t(t>1))+26*cos(2*pi*17*t(t>1))+21*sin(2*pi*29*t(t>1))+10*randn(size(t));
z=[x';y'];
plot(t',z);
但它使用+
Matrix dimensions must agree.
Error in time_frequency (line 7)
x=25*sin(2*pi*23*t(t<1))+20*cos(2*pi*24*t(t<1))+24*sin(2*pi*22*t(t<1))+10*randn(size(t));
在那裏我有錯尺寸顯示我的錯誤錯誤?也是這個問題的修復後認爲代碼對應的情況,我想提前右感謝
更新:
% non stationary signal with time varying frequency
fs=100 ; % sampling frequency
ts=1/fs;
t=(0:ts:2.93); % time vector
t1=t(t<1);
t2=t(t>=1);
wn=10*randn(size(t1));
wn1=10*randn(size(t2));
% i want to create signal which consist of sinusoidal components in
% addtiive of white noise , frequencies are defined in time as
x=25*sin(2*pi*23*t(t<1))+20*cos(2*pi*24*t(t<1))+24*sin(2*pi*22*t(t<1))+wn;
y=21*sin(2*pi*20*t(t>=1))+26*cos(2*pi*17*t(t>=1))+21*sin(2*pi*29*t(t>=1))+wn1;
z=[x';y'];
plot(t',z);
你的問題,然後'randn()'在你的x,y定義的末尾。您正在嘗試添加不同維度的數組。大小(t)的結果是't(t <1)' or 't(t> 1)'的另一個值。 – 2014-10-10 10:31:58
aa所以我應該在 – 2014-10-10 10:32:36
之前定義它或者你可以使用'randn(size(t(t <1)))'或者你可以忽略它並且在你定義'z'之後做'z = z + 10 * randn(size (噸))'。這些都應該工作 – 2014-10-10 10:33:50