Subscripted assignment dimension mismatch.
9 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!