Approximating /transforming /absolute error

input data
r=3;h=8;Dv=0.1;
Dr=(Dv/3)*(1/(1/3*pi*h*2*r))
the result is 6.6315e-04 , how do i transform /aproximate/etc the result on the left to 0.00066 ? I ran a conversion to decimal using Symbolab (website) and the exact result of the conversion is 0.00066315 .

 採用された回答

Alan Stevens
Alan Stevens 2020 年 10 月 27 日

1 投票

For display purposes you can use fprintf:
>> r=3;h=8;Dv=0.1;
Dr=(Dv/3)*(1/(1/3*pi*h*2*r));
fprintf('%0.2g \n',Dr)
0.00066

7 件のコメント

Opariuc Andrei
Opariuc Andrei 2020 年 10 月 27 日
Thank you
Opariuc Andrei
Opariuc Andrei 2020 年 10 月 28 日
編集済み: Opariuc Andrei 2020 年 10 月 28 日
i have another question related to this topic. How can i write to get 0.01 precision ? or higher
Alan Stevens
Alan Stevens 2020 年 10 月 28 日
Do you mean like this
>> r=3;h=8;Dv=0.1;
Dr=(Dv/3)*(1/(1/3*pi*h*2*r));
fprintf('%0.6g \n',Dr)
0.000663146
Type doc fprintf in the command window for more details on controlling the output with fprintf.
Opariuc Andrei
Opariuc Andrei 2020 年 10 月 28 日
i've got a rectangular parallelepiped with the base a rectangle having the sides of the base A ≈ 15 mm and B ≈ 20 m and height H ≈ 25 m. The body is drilled vertically with a drill with a diameter D ≈ 3 mm. i'm supposed to determine the absolute errors in determining the values ​​A, B, H, D so that the body volume can be calculated with a accuracy of 0.01 mm3. this is what i'm referring to .
Alan Stevens
Alan Stevens 2020 年 10 月 28 日
That's an entirely different question! fprintf merely alters the way the number displays, it doesn't alter the size of the values that have been used internally.
If you assume the absolute error is the same on A, B, H and D, (say, delta mm), then fzero will find the value of delta that makes the body Volume have an absolute error of 0.01mm^3. For example
delta0 = 10^-5;
delta = fzero(@dfn,delta0);
disp(delta)
fprintf('delta = %0.7f mm\n',delta)
function tol = dfn(delta)
A = 15 + delta; % mm
B = 20 + delta; % mm
H = 25 + delta; % mm
D = 3 + delta; % mm
Vtol = 0.01; % mm^3
% Volume with error Nominal volume Volume tolerance
tol = A*B*H-pi*D^2/4 - (15*20*25 - pi*3^2/4) - Vtol;
end
fzero adjusts delta until the value returned from dfn is as close to zero that it can get.
tol returns the difference between the volume .
If these aren't the right equations for you, then modify to suit.
Opariuc Andrei
Opariuc Andrei 2020 年 10 月 28 日
Oh master , please accept my humble thank you :)
Alan Stevens
Alan Stevens 2020 年 10 月 28 日
You're welcome. Note that I've suggested a very simplistic approach. A more advanced approach might involve a Monte-Carlo simulation and/or allow different tolerances on each of A, B etc.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

製品

リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by