Subscripted assignment dimension mismatch.

8 visualizaciones (últimos 30 días)
Mustapha hamaoui
Mustapha hamaoui el 29 de Nov. de 2016
Comentada: Walter Roberson el 29 de Nov. de 2016
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Nov. de 2016
"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 comentarios
Mustapha hamaoui
Mustapha hamaoui el 29 de Nov. de 2016
Thanks Walter, but Pm is a Scalar and g is a matrix with 5000 value
Walter Roberson
Walter Roberson el 29 de Nov. de 2016
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)

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by