Subscripted assignment dimension mismatch.

7 ビュー (過去 30 日間)
Mustapha hamaoui
Mustapha hamaoui 2016 年 11 月 29 日
コメント済み: Walter Roberson 2016 年 11 月 29 日
Hi, please i got this error from Matlab. I don't know what the problem
for j=1:5000
g=Qom(j)
Pm=Pm
r(j)=xcorr([Pm,g],'coeff')
end

採用された回答

Walter Roberson
Walter Roberson 2016 年 11 月 29 日
"If x is an M × N signal matrix representing N channels in its columns, then xcorr(x) returns a (2*M – 1) × N^2 matrix with the autocorrelations and mutual cross-correlations of the channels of x"
The only time that could give you a scalar output would be if M = 1 and N = 1 -- that is, if you had a scalar input. But unless your Pm is empty, [Pm,g] is going to be a vector, and so the minimum output size you could get would be a 3 x 1 column vector (and might be larger, if Pm is larger.). You cannot store a 3 x 1 column vector into the single location r(j)
  2 件のコメント
Mustapha hamaoui
Mustapha hamaoui 2016 年 11 月 29 日
Thanks Walter, but Pm is a Scalar and g is a matrix with 5000 value
Walter Roberson
Walter Roberson 2016 年 11 月 29 日
g=Qom(j)
so g cannot be a matrix. g must be a scalar. So you are using [scalar,scalar] which results in a vector of length 2. So you are using a 1 x 2 input array. M = 1, N = 2. That is going to give you a (2 * M - 1) by (N^2) output, which is (2*1 - 1) by (2^2) which is 1 by 4 output.
... or it would if xcorr were not treating row vector as a special case. It is treating it as a 2 x 1 input, so (2 * 2 - 1) by (1^2) which is 3 x 1, then transposing because the original is a row vector, so the output is 1 x 3.
1 x 3 is not going to fit in a single location r(j)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by