evalit.m v3 (Jul 2013)

Evaluates a mathematical expression and rounds it accordingly to the error propagation theory.
356.0 次下载
更新时间 2013/7/22

查看许可证

HAVE YOU EVER WONDERED HOW MANY DIGITS SHOULD YOU USE FROM A CALCULATOR RESULT?

Well, this function will do it for you.

For example, let's calculate Earth's gravity:

>> % Symbolic inputs:
>> syms G M R
>> g = G*M/R^2;
>>
>> % Numerical inputs:
>> Gu=6.67384e-11; eGu=0.00080e-11; % Newton's Gravitational Constant and its error.
>> Me=5.97e24; eMe=-3; % 3 significant figures for Earth's mass.
>> Re=6.371e6; eRe=-4; % 4 significant figures for Earth's radius.
>>
>> % And the calculation:
>> evalit(g,{G M R},[Gu Me Re],[eGu eMe eRe])

So we get:

EVALIT: FUNC(G,M,R) = (G*M)/R^2
--------------------------------------------------
value +/- error (arguments' error contributions)
--------------------------------------------------
9.8160 +/- 0.0085 ( 0.0012 + 0.0082 + 0.0015 )
--------------------------------------------------

That is:
g = (9.8160 ± 0.0085) N/kg
instead of
g = 9.816008178047202... N/kg

As you can see, you'll also get the error contributions of each factor.
In this case, the Earth's mass (2nd one) results with the biggest error: 0.0082 N/kg.
While G contributes with the smallest error.

But most important is that all errors from every factor (G, M and R) have the same order of magnitude.

Besides...
- It works with matrix inputs.
- It andles function_handles (@'s) instead of symbolic expressions.
- It gives numerical and/or printed results.
- It exhaustively checks the inputs so it helps with input mistakes.
- It uses as minumum error the double-precision floating point (since v2).
- Inputs may be arrays of (almost) any kind: cells, matrixes, vectors (v3).
- Empty, zero, INF or NAN errors are changed to double floating point precision errors (v3).
- It uses first order error approx. but checks if they satisfy to be smaller than the second order ones (v3).
- It uses higher order error approx. when the first one is zero (v3).

Enjoy it!
Carlos Vargas

引用格式

Carlos Adrian Vargas Aguilera (2024). evalit.m v3 (Jul 2013) (https://www.mathworks.com/matlabcentral/fileexchange/42307-evalit-m-v3-jul-2013), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2008b
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.5.0.0

Now handles COMPLEX VALS. Fixed bug when VARS dos not coincide with FUNC's arguments. VARS and PDS input arrays can be cells or matrix. Other minor changes.

1.2.0.0

Now it handles double precision floating point. Other minor changes.

1.0.0.0