필터 지우기
필터 지우기

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