使用*内部矩阵尺寸时出错必须同意

时间:2015-04-24 00:43:57

标签: matlab matlab-figure matlab-guide telecommunication

我正在尝试在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;

1 个答案:

答案 0 :(得分:2)

通过在*:

之前添加一个点来尝试元素乘法
x = (Ac + m).*cos(2*pi*fc*t);