MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB数学相关] 这个程序哪里错了啊??跪求!!! (https://www.labfans.com/bbs/showthread.php?t=14205)

51qiang168 2011-12-26 12:56

这个程序哪里错了啊??跪求!!!
 
f1=35;f2=50;dt=0.004;
n=0:149;
x=sin(2*pi*f1*n*dt);
y=0.8*cos(0.4*pi*n)*exp(-100*n.^2*dt.^2);
figure(1);
stem(x,'.');
figure(2);
stem(y,'.');
matlab中总是报错:??? Error using ==> mtimes
Inner matrix dimensions must agree.

Error in ==> Untitled2 at 5
y=0.8*cos(0.4*pi*n)*exp(-100*n.^2*dt.^2);
把y=..............这个去掉或者是把y=..........后面的exp(...)去掉就正常,为什么???????????

yhcode 2011-12-26 15:16

回复: 这个程序哪里错了啊??跪求!!!
 
好好看看malab矩阵运算中的点操作及正常的算术运算操作。非点操作类运算必须满足矩阵维数要求,如矩阵乘法必须满足m*k 与 k*n矩阵相乘

纵马扬鞭 2011-12-26 16:55

回复: 这个程序哪里错了啊??跪求!!!
 
那个n是矩阵,所以*成了矩阵乘矩阵了。若用.*就是两矩阵对应元素相乘。我以前也经常不小心敲错


所有时间均为北京时间。现在的时间是 16:51

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.