1.0

1.0 | 1 rating Rate this file 17 Downloads (last 30 days) File Size: 1.17 KB File ID: #33595

Code for calculating root mean squared error for data

by

 

03 Nov 2011 (Updated )

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

| Watch this File

File Information
Description

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.

Required Products MATLAB
MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
04 Jul 2013 Jan Simon

"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))"

08 Dec 2011 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
18 Dec 2011

for loops were eliminated for fast implementation.

01 Jul 2013

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

11 Jul 2013

modified to display proper message while matrix dimension mismatch.

Contact us