Subscripted assignment dimension mismatch.

7 Ansichten (letzte 30 Tage)
Mustapha hamaoui
Mustapha hamaoui am 29 Nov. 2016
Kommentiert: Walter Roberson am 29 Nov. 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by