File Exchange

image thumbnail

Code for calculating root mean squared error for data

version 1.4 (1.17 KB) by

This is a simple code which accurately calculates RMS error for real or complex data.

1 Download

Updated

View License

er = rms_error(A1,A2)

here A1, A2 are original and reconstructed data. The order of A1,A2 doesn't matter, interchanging them will also give same result.

Comments and Ratings (2)

Jan Simon

Jan Simon (view profile)

"numel(A1)" looks nicer than "size(A1(:),1)".

The comparison of "size(A1)~=size(A2)" crashes, if the number of dimensions differs. Therefore this is smarter: "~isequal(size(A1), size(A2))"

Michael Völker

MATLAB = MATrix LABoratory

er = A1 - A2;
er = sqrt( (er(:)' * er(:)) / length(er(:)) );

Advantages: faster, shorter, works with arbitrarily sized A1/A2, works with complex data, too.

Updates

1.4

modified to display proper message while matrix dimension mismatch.

1.3

No update in the code, only changed the description of code

1.2

for loops were eliminated for fast implementation.

MATLAB Release
MATLAB 7.5 (R2007b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video