code for calculating root mean square error of two quantities having different dimensions?

I am doing floating to fixed point conversion. output of Fixed point conversion has different dimensions than the same of floating point engine. How to calculate root mean square error in such a case?
er = M - x; er = sqrt((er(:)'*er(:))/length(er(:))); Using the above formulas, matlab's giving error that matrix dimensions must agree

1 个评论

Fix the output to have the same number or truncate the longer of the two to the shorter. It makes no sense to talk of a error if there's nothing to compare to.

请先登录,再进行评论。

 采纳的回答

I assume it is the line
er = M - x;
that is giving the error. Do M and x have different dimensions, but the same number of elements? If so, then try transposing one of the vectors like this:
er = M' - x;
If they have different number of elements, then I am completely befuddled as to how you expect to calculate the error from these two variables. There must be a one-to-one comparison for the error to make sense (most of the time).

2 个评论

Hi,
thanks for the reply. M & x have different number of elements. I am trying to truncate the larger of the two to the smaller one & then trying to find the error.
But, this is so confusing. Do M(1) and x(1) really correspond to each other, such that that is a valid measure of error? What about M(7234) and x(7234)?
Or is it more complicated, with M and x being sampled at different rates or times, such that there is not a one-to-one correspondence?

请先登录,再进行评论。

更多回答(1 个)

Agree w/ cycler that it's confusing why this should be so, but the answer to the question ...trying to truncate the larger of the two to the smaller one & then trying to find the error is pretty simple.
N=min(length(M), length(x));
er=M(1:N)-x(1:N);
Now, whether that really makes any sense or not is beyond the amount of information we have to judge but it should solve your immediate problem programmatically, anyway.

2 个评论

thanks for the answer. I am doing 32 bit floating to 24 bit fixed point conversion of an audio signal. Number of elements in one dimension of sampled data of both cases are slightly different from each other. That's the reason why I am finding the rms error in this way.
Would seem like in that case you'd be better off resampling to a constant time base.

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by