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일

0 개 추천

"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
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개)

카테고리

태그

질문:

2016년 11월 29일

댓글:

2016년 11월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by