code for calculating root mean square error of two quantities having different dimensions?
10 views (last 30 days)
Show older comments
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 Comment
dpb
on 27 May 2014
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.
Accepted Answer
the cyclist
on 27 May 2014
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 Comments
the cyclist
on 27 May 2014
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?
More Answers (1)
dpb
on 27 May 2014
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 Comments
dpb
on 27 May 2014
Would seem like in that case you'd be better off resampling to a constant time base.
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!