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

2 次查看(过去 30 天)
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

采纳的回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023-10-20
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by