Created
September 1, 2014 04:35
-
-
Save tinybike/1e3480193980481ec164 to your computer and use it in GitHub Desktop.
convert a number and its error to a more readable version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [u_sig,u_paren] = pretty_errors(u,u_err) | |
% Convert a number and its error to a more readable version: | |
% Ex: | |
% u = 1.234567, u_err = 0.012345 -> u_sig = '1.23', u_paren = '1' | |
% (for use with notation u = 1.23(1)) | |
n = -1; | |
u_paren = 0; | |
while ~u_paren | |
n = n + 1; | |
u_paren = round(u_err*10^n); | |
end | |
u_paren = num2str(u_paren); | |
u_sig = num2str(round(u*10^n)/10^n); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment