How to convert PgArray to Matlab array?

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by