2015-04-24 59 views
2

我想計算MATLAB的一些功能,我得到這個錯誤:錯誤使用*內矩陣維度必須同意

Error using * 
Inner matrix dimensions must agree. 

Error in set1 (line 11) 
x = (Ac + m)*cos(2*pi*fc*t); 

,但我不使用任何類型的矩陣在我的代碼。有什麼問題?

這裏是我的代碼:

fs = 10000; 
Ts = 1/fs; 
t = (0:Ts:10); 
m = cos(2*pi*t); 
plot(t,m); 
figure; 

Ac = 2; 
fc = 500; 
x = (Ac + m)*cos(2*pi*fc*t); 
plot(t,x); 
figure; 

回答

2

嘗試的elementwise乘以之前*加點:

x = (Ac + m).*cos(2*pi*fc*t); 
+0

謝謝!這是問題所在 – athinatha