Reading data from a sqlite database

3 ビュー (過去 30 日間)
Keihan
Keihan 2023 年 12 月 6 日
回答済み: Samay Sagar 2024 年 9 月 25 日
Hi,
I'm trying to import data from a sqlite database. Some of the data in the database are floating point values that are less than 1. When I run the MATLAB fetch command to read the data, the result is a cell array with zero values:
{[0]}, {[0]},....
Then when I run cell2mat to convert the cell array to a numeric array, I get an array of zeros.
The fetch command is:
values = fetch(conn, sqlquery);
How do I should read database values that are less than 1 floating point numbers?
Thank you,
Keihan Rafii
  1 件のコメント
Mann Baidi
Mann Baidi 2023 年 12 月 7 日
編集済み: Mann Baidi 2023 年 12 月 7 日
Hi,
I am not facing any issue in fetching floating values that are less than 1 on my end. Can you share the database and the query which you are trying to fetch?

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

回答 (1 件)

Samay Sagar
Samay Sagar 2024 年 9 月 25 日
You might encounter the above issue if the data type is not handled correctly.
You can follow these steps to ensure that the data is imported correctly:
  1. Ensure that the columns in your SQLite database are defined with a floating-point type (e.g., "REAL").
  2. Before converting the data to matrix, inspect the raw data fetched from the database to verify the values. You can set up breakpoints in your code to inspect variable values.
  3. If the values are too small(say 0.0000001), the values can appear as 0 due to loss in precision. You can change the display format to long to resolve this.
format long
For more information related to debugging, you can refer the following documentation:

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by