How to fix Unable to perform assignment because the left and the right sides have different number of elements?

1 次查看(过去 30 天)
I also used IR_stats.m but when i ran the program, it went :
------------------------------------------------
ff
Unable to perform assignment because the left and right sides have a different number of elements.
Error in IR_stats (line 183)
t0(n) = find(x(:,n).^2==max(x(:,n).^2)); % find direct impulse
Error in ff (line 1)
[rt,drr,cte,cfs,edt] = IR_stats('imppp.wav','spec','full');
----------------------------------------------
btw, my ff codes are :
[rt,drr,cte,cfs,edt] = IR_stats('imppp.wav','spec','full');
i already inserted the imppp.wav
  3 个评论
Walter Roberson
Walter Roberson 2020-5-3
You could have done max() with two outputs if you just want to find the location of one location that happens to have the same maximum absolute value. You would be sure of getting exactly 1 position, except in the case that x was empty.
But you did not do that: instead you take the maximum and compare every other location to that maximum. There could be multiple locations that match. And you ask for all of them. This appears to be deliberate coding on your part, to ask for all of them.
But you then store that list of all places that have the maximum, and you try to store it into a single numeric location t0(n) .
Consider if you had the input [0 -1/2 -1 -1/2 0 1/2 1 1/2 0] . Then x.^2 would be [0 1/4 1 1/4 0 1/4 1 1/4 0]. max() of that is 1. compare the squares to that 1 and you find that 3 and 7 match. Do you want both locations to be recorded, since they are both maximal? If not, then which of them do you want recorded? [~,t0(n)] = max(x.^2) would choose exactly one of the two locations, order uncertain unless you use the 'stable' option, but it would be only one.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by