How can I obtain the difference between two data stored in workspace?

Illustration
saleh shlimet - 2023-12-05T15:15:56+00:00
Question: How can I obtain the difference between two data stored in workspace?

I experimentally tested a motor and the measured speed and the reference speed were stored in the workspace. My supervisor asked me to obtain the speed error (the difference between the reference and the measured speed). How can I obtain it from the data stored in the workspace? 

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

If the two variables have the same number of elements, just subtract one from the other.
 
For example:
 
 
speed_error = reference - measured
That will give the error at each element of each vector.
 
If you want to get a single parameter with respect to the ‘speed_error’ vector, one option is to use the rms function to get the RMS error. To get the mean squared error, simply square the RMS result.
 
There are other options as well. The sum squared error is simply:
 
 
sum_squared_error = sum(speed_error.^2)

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!