Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

??? Index exceeds matrix dimensions.

1 vue (au cours des 30 derniers jours)
Devinya Herath
Devinya Herath le 1 Oct 2011
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaires
Devinya Herath
Devinya Herath le 1 Oct 2011
I didn't get you
Jan
Jan le 1 Oct 2011
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.

Réponses (1)

the cyclist
the cyclist le 1 Oct 2011
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 commentaires
Devinya Herath
Devinya Herath le 1 Oct 2011
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 le 1 Oct 2011
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.)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by