フィルターのクリア

How to convert PgArray to Matlab array?

2 ビュー (過去 30 日間)
Atanu
Atanu 2022 年 3 月 13 日
編集済み: Atanu 2022 年 4 月 23 日
I have written a SQL query to import a table into MATLAB. There is 2 two PgArrays ('org.postgresql.jdbc.PgArray') in the workspace. I need to plot those arrays. How do I convert PgArrays to numeric array so that it is in more manageable format?
datasource = 'live_database';
conn = database(datasource,'postgres','1234');
tablename = "live_table";
query = "SELECT date, coordinatetimes," + ...
" xcoordinates, ycoordinates FROM live_Table WHERE subjectid = 'andrea';";
data = fetch(conn,query);

採用された回答

Atanu
Atanu 2022 年 4 月 23 日
編集済み: Atanu 2022 年 4 月 23 日
This piece of code will convert PGArray data to double
all_coordinatetimes = cell(length(data_on_date.coordinatetimes),1);
for idx = 1:length(data_on_date.coordinatetimes)
string_all_coordinatetimes = string(data_on_date.coordinatetimes(idx,1));
reg_all_coordinatetimes = regexprep(string_all_coordinatetimes,'{|}','');
split_all_coordinatetimes = split(reg_all_coordinatetimes,',');
all_coordinatetimes{idx,1} = str2double(split_all_coordinatetimes);
data_on_date.coordinatetimes{idx,1} = all_coordinatetimes{idx,1};
end

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by