Info

此问题已关闭。 请重新打开它进行编辑或回答。

??? Index exceeds matrix dimensions.

2 次查看(过去 30 天)
Devinya Herath
Devinya Herath 2011-10-1
关闭: MATLAB Answer Bot 2021-8-20
I have a postgres table that contains 576078 records. I want to access the record with the primary key of '344149'. The primary key field is of type integer.
To get the record to matlab I wrote the following code and get the error message "??? Index exceeds matrix dimensions."
curs2 = exec(conn, 'select sp_x, sp_y, ep_x, ep_y from road_part6_trajectories_oneway2_new_segments_cartesian where new_total_segment_id=344149');
format long;
curs2 = fetch(curs2, 1);
BB = curs2.Data;
y1 = BB{1,2};
Please help
  3 个评论
Jan
Jan 2011-10-1
Please use code formatting - follow the "Markup help" link on this page to find out more. I've applied the code formatting for you this time: Mark the code section, press on the "{} code" button, ready. This is not much work, but friendly for all readers who want to assist.

回答(1 个)

the cyclist
the cyclist 2011-10-1
I can think of two things that could cause this error:
  • Your query returns no rows, in which case it will be reported as a cell with "No Data". Because there is no {1,2} element of BB, you get that error message.
  • Your query has a postgresql error, resulting in BB having the value "0". Again, because there is no {1,2} element of BB, you get that error message.
Can you breakpoint the code just before MATLAB throws that error, and see if either of those things are happening?
Do you have any other software (e.g. pgAdmin) that would allow you to double-check the query itself, to see if it is valid?
  2 个评论
Devinya Herath
Devinya Herath 2011-10-1
yes. When I isolate the problem, I discovered that this happens because of the first reason you have mentioned. But my worry is the actual table had data in this row (row with new_total_segment_id=344149').
the cyclist
the cyclist 2011-10-1
If you are seeing "No Data" as a result, there is no MATLAB error here. You need to do more of a postgresql debugging. Maybe you could try other values (or a range) of the primary key. (You could try eliminating the where clause completely, but that might be too many rows for MATLAB memory to handle.)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by