フィルターのクリア

Getting "??? Error using ==> mtimes Inner matrix dimensions must agree" error

2 ビュー (過去 30 日間)
Ruqayya
Ruqayya 2014 年 9 月 7 日
回答済み: Star Strider 2014 年 9 月 7 日
t0=0.1;
ts=0.0001;
fs=1/ts;
t= [0:ts:t0-ts]
m=sinc(100*t);
fc=250;
c=cos(2*3.14*fc*t);
u=m*c;

回答 (2 件)

Sagar Damle
Sagar Damle 2014 年 9 月 7 日
In the statement
u = m * c;
MATLAB tries for 'matrix multiplication'.Marix multiplication is possible when a matrix of dimension (m * n)[rows = m,columns = n] is multiplied with another matrix of dimension (n * p).The dimension of answer matrix will be (m * p).Or otherwise,one of two matrices in matrix multiplication should contain just a single value(scalar matrix). Here,neither 'm' nor 'c' is single-valued. Or if you want elementwise multiplication,you can use
u = m. * c;
N.B. : You can use inbuilt value for pi using 'pi'.
c=cos(2*pi*fc*t);

Star Strider
Star Strider 2014 年 9 月 7 日
Hi Ruqayya —
This is the line that is throwing the error:
u=m*c;
where both ‘m’ and ‘c’ are (1x1000) double vectors.
Two possibilities present themselves, since I don’t know what you want:
  1. —> ‘u’ is intended to be a (1x1000) double vector as well, in which situation u=m.*c; (note the ‘.*’ indicating element-by-element multiplication as opposed to vector or matrix multiplication);
  2. —> ‘u’ is intended to be a (1x1) double scalar, in which situation u=m*c'; (note the transpose operator (') after the c, keeping m as (1x1000) double row vector and creating c to a (1000x1) double column vector.
Your call as to what you want ‘u’ to be. One of these should work in your application. Neither of them will throw the error.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by