Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

??? Index exceeds matrix dimensions.

2 Ansichten (letzte 30 Tage)
Devinya Herath
Devinya Herath am 1 Okt. 2011
Geschlossen: MATLAB Answer Bot am 20 Aug. 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 Kommentare
Devinya Herath
Devinya Herath am 1 Okt. 2011
I didn't get you
Jan
Jan am 1 Okt. 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.

Antworten (1)

the cyclist
the cyclist am 1 Okt. 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 Kommentare
Devinya Herath
Devinya Herath am 1 Okt. 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 am 1 Okt. 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.)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by