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

3 views (last 30 days)

Show older comments

saleh shlimet
on 30 Nov 2023

Commented: Star Strider
on 4 Dec 2023

##### 5 Comments

### Accepted Answer

Star Strider
on 30 Nov 2023

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)

.

##### 5 Comments

Star Strider
on 4 Dec 2023

### More Answers (0)

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!