RMSE - Root Mean Square Error in MATLAB Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report RMSE or Root Mean Squared Error is a general-purpose error estimation that is calculated by computing the square root of the summation of the square of the difference of the prediction of an experiment and its actual/expected value. RMSE is a good error estimation as it tells us how far a line is fit from its actual value. Fields such as Machine Learning and Numerical Analysis have extensive requirements if this measure of error calculation. Let us see how the same can be done in MATLAB. Method 1: Manually Calculating the RMSEThe mathematical formula for calculating RMSE is:RMS = \sqrt{\sum _{N}^{i-0}\left [ Predicated i - Actual i \right ]^{2}}/ N Example 1: Matlab % The code for calculating the same in MATLAB % Data expected = [31 23 14 10.5 6.5]; experimental = [32.5 21.9 15.1 9 5.2]; % Calculating rmse diff = sum((experimental - expected).^2); rm = sqrt(diff/5); disp(rm) Output: Method 2: Calculating RMSE with RMS() There is an easier way of doing this in a single step i.e., with the inbuilt RMS() function which takes the error as input and calculates the RMSE of the same. Matlab % MATLAB code for RMS() expected = [31 23 14 10.5 6.5]; experimental = [32.5 21.9 15.1 9 5.2]; % Error vector diff = experimental-expected; % Using the rms() function r = rms(diff) Output: As can be seen in the above two methods that the value of RMSE is the same when calculated manually and when calculated by the built-in RMS() function. So, depending on the user's choice, either of the methods could be used. Create Quiz Comment O owl0223 Follow 0 Improve O owl0223 Follow 0 Improve Article Tags : Software Engineering MATLAB-Maths Explore Software Engineering BasicsIntroduction to Software Engineering7 min readSoftware Development Life Cycle (SDLC)6 min readSoftware Quality - Software Engineering5 min readISO/IEC 9126 in Software Engineering4 min readBoehm's Software Quality Model4 min readSoftware Crisis - Software Engineering3 min readSoftware Measurement & MetricesSoftware Measurement and Metrics4 min readPeople Metrics and Process Metrics in Software Engineering7 min readHalsteadâs Software Metrics - Software Engineering10 min readCyclomatic Complexity6 min readFunctional Point (FP) Analysis - Software Engineering8 min readLines of Code (LOC) in Software Engineering4 min readSoftware Development Models & Agile MethodsWaterfall Model - Software Engineering12 min readWhat is Spiral Model in Software Engineering?9 min readPrototyping Model - Software Engineering7 min readIncremental Process Model - Software Engineering6 min readRapid Application Development Model (RAD) - Software Engineering9 min readCoupling and Cohesion - Software Engineering10 min readAgile Software Development - Software Engineering15+ min readSRS & SPMSoftware Requirement Specification (SRS) Format5 min readSoftware Engineering | Quality Characteristics of a good SRS7 min readSoftware Project Management (SPM) - Software Engineering8 min readCOCOMO Model - Software Engineering15+ min readCapability Maturity Model (CMM) - Software Engineering10 min readIntegrating Risk Management in SDLC | Set 18 min readSoftware Maintenance - Software Engineering13 min readTesting & DebuggingWhat is Software Testing?11 min readTypes of Software Testing15+ min readTesting Guidelines - Software Engineering3 min readWhat is Debugging in Software Engineering?11 min readVerification & ValidationVerification and Validation in Software Engineering6 min readRole of Verification and Validation (V&V) in SDLC5 min readRequirements Validation Techniques - Software Engineering8 min readPractice QuestionsTop 50+ Software Engineering Interview Questions and Answers15+ min read Like