File Exchange

## Propagation of Uncertainty

version 1.3.0.0 (1.63 KB) by
Returns the propagated uncertainty in a function F imparted to it from its variables

17 Downloads

Updated 17 Oct 2014

View License

(UPDATE: Feel free to use this code, but I have written another much better code here: http://www.mathworks.com/matlabcentral/fileexchange/48139-worst-case-propagation-of-uncertainty)
Handy little function, for those of you in lab classes where they are sticklers for error. (or for those of you that are actual scientists even...!).

Propagation of uncertainty is a really slick formula, but its a massive pain to do by hand. this function does it for you!

To do it, just enter in the symbolic function, a row vector of the variables, a row vector for the estimated values of those variables, and lastly a row vector of the uncertainty associated with those variables.
help PropError has an example in it.
Enjoy!
outputs both actual error, and the percent error.

The program follows the equation shown in the screenshot. (courtesy of Wikipedia).
Requires Symbolic Math Toolbox.

### Cite As

Brad Ridder (2021). Propagation of Uncertainty (https://www.mathworks.com/matlabcentral/fileexchange/17901-propagation-of-uncertainty), MATLAB Central File Exchange. Retrieved .

### Comments and Ratings (14)

Michael Darmanis

Timothy Kenna

Benoit Landry

Line error1 =sqrt( sum((subs(sig,varlist,vals).^2).*(errs.^2)) ); should be replaced with
error1 =sum(abs(subs(sig,varlist,vals).*errs));

This is because sqrt(x1^2+x2^2) ~= abs(x1)+abs(x2)

Till Schnabel

Francesco Ghini

I have a complicated experimental function, where I have to perturb two variables at the same time to simulate accuracy (rather than precision).

Is it possible with PropError?

Thank you in advance

Deepak Ramaswamy

@Konstantinos, It seems this should fix display.
res = PropError(...);
res{1,1} = double(res{1,1});
res{2,3} = double(res{2,3})

Konstantinos

Hi,
thanks for your script.

I have a problem though. When I run the script, it does not return the result of the function nor the error in percentage.
Here is what i get:

[1x1 sym] '+/-' [3.1719e-04]
'Percent Error' '+/-' [1x1 sym]

so, instead of getting the values, i get the [1x1 sym].

Can you please help me understand why this is happening ? Is the first time i am using the Symbolic Math Toolbox.
Cheers,
Konstantinos

Rhys

Very Nice! Very helpful for my Modern Physics lab!

xiong

So simple and useful, Thank you

Marcus

sixie yu

Help me solve the physic experimental uncertainty.

Arne

Simple, accurate and powerful. Just what I needed. Thank you

##### MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
##### Platform Compatibility
Windows macOS Linux

### Community Treasure Hunt

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

Start Hunting!