How to remove trailling numbers when using the update function (database toolbox)

1 vue (au cours des 30 derniers jours)
Hi,
Im using the update function from the database toolboox to update data in an Oracle database
conn = database(env, user, pass)
tablename = 'depth_table';
whereclause = 'where set_id = 1';
p_var = 'depth_p';
d = [1,1,1,1]';
p = table(0.01 * ones(height(d), 1), 'VariableNames', {'depth_p'});
update(conn, tablename, p_var, p, whereclause)
The problem is that the 0.01 value in Matlab becomes 0.010000000003456346 in Oracle (its a simple number field in Oracle). How can I stop this from happening ?
Thank you

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 20 Oct 2023
Maybe to store data in a single() format instead of double (default in MATLAB), and also, round up the values, e.g.:
t = linspace(0, 2*pi, 10);
t = round(t, 3, 'significant'); % Round to 3 significant digits
ts = single(t);
F = sin(t);
F = round(F, 3, 'significant'); % Round to 3 significant digits
Fs = single(F);
T = array2table(ts');
T.Fun = Fs'
T = 10×2 table
Var1 Fun _____ ________ 0 0 0.698 0.643 1.4 0.985 2.09 0.868 2.79 0.344 3.49 -0.341 4.19 -0.867 4.89 -0.984 5.59 -0.639 6.28 -0.00319

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by