Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7962711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:24:51+00:00 2026-06-04T05:24:51+00:00

This system is to generate the distance using two points of coordinates. Sheet 1

  • 0

This system is to generate the distance using two points of coordinates.
Sheet 1 display the coordinate on each waypoint, Sheet 2 display the connection of the waypoints.

Hence I’m require to generate the distance out but I keep encounter this problem; “??? Index exceeds matrix dimensions.” How can I solve this problem.

Below are my coding and the data stored in excel.

Coding

M = xlsread('Region11.xlsx',1);  
N = xlsread('Region11.xlsx',2);
Start = N(:,1);
End = N(:,2);
distance = distance([M(Start,3),M(Start,4)],[M(End,3),M(End,4)]);
a= deg2km(distance);
xlswrite('Region11.xlsx',a, 2,'C2');

Region11 – sheet 1

No. Waypoints Latitude Longitude
1   11001   1.37983 103.84421
2   11002   1.3808  103.84406
3   11003   1.38186 103.84375
4   11004   1.38376 103.84301
5   11005   1.3838  103.84293
6   11006   1.38361 103.84153
7   11007   1.38354 103.84118
8   11008   1.38342 103.84088
9   11009   1.38308 103.84022
10  11010   1.38301 103.8402
11  11011   1.37973 103.84191
12  11012   1.37964 103.84201
13  11013   1.37963 103.84206
14  11014   1.37983 103.8441
15  11015   1.38003 103.84408
16  11016   1.38003 103.84408
17  11017   1.37998 103.84411
18  11018   1.37982 103.84403
19  11019   1.37984 103.84371
20  11020   1.37991 103.84373
21  11021   1.37994 103.8439
22  11022   1.38001 103.84328
23  11023   1.37993 103.84315
24  11024   1.37977 103.8431
25  11025   1.37981 103.84308
26  11026   1.37978 103.84269
27  11027   1.37972 103.84266
28  11028   1.37948 103.84253
29  11029   1.37955 103.84232
30  11030   1.37965 103.84197
31  11031   1.37981 103.84188
32  11032   1.37987 103.84196
33  11033   1.38004 103.84175
34  11034   1.3801  103.84187
35  11035   1.38018 103.8417
36  11036   1.38024 103.84179
37  11037   1.38008 103.84207
38  11038   1.38021 103.84201
39  11039   1.37997 103.84213
40  11040   1.38013 103.8429
41  11041   1.38021 103.84289
42  11042   1.38022 103.84289
43  11043   1.38028 103.84367
44  11044   1.38028 103.84367
45  11045   1.38026 103.84363
46  11046   1.38052 103.844
47  11047   1.38053 103.84398
48  11048   1.38059 103.84407
49  11049   1.38099 103.84394
50  11050   1.381   103.84391
51  11051   1.3811  103.84388
52  11052   1.38108 103.84393
53  11053   1.38122 103.84387
54  11054   1.38127 103.84392
55  11055   1.38127 103.84384
56  11056   1.3816  103.8437
57  11057   1.38164 103.84374
58  11058   1.38169 103.84381
59  11059   1.38158 103.84354
60  11060   1.38157 103.84349
61  11061   1.38135 103.84289
62  11062   1.38133 103.84288
63  11063   1.38125 103.84286
64  11064   1.38124 103.84285
65  11065   1.38083 103.84286
66  11066   1.38083 103.84286
67  11067   1.38099 103.84203
68  11068   1.381   103.84203
69  11069   1.3817  103.841
70  11070   1.3817  103.84099
71  11071   1.38166 103.84094
72  11072   1.38199 103.84076
73  11073   1.38199 103.84076
74  11074   1.3824  103.84053
75  11075   1.3824  103.84053
76  11076   1.38242 103.84053
77  11077   1.38242 103.84053
78  11078   1.38247 103.84046
79  11079   1.38292 103.84028
80  11080   1.38291 103.84043
81  11081   1.38291 103.84039
82  11082   1.38295 103.84072
83  11083   1.38291 103.8407
84  11084   1.38306 103.84051
85  11085   1.38323 103.84038
86  11086   1.38338 103.84067
87  11087   1.38329 103.84069
88  11088   1.38331 103.84091
89  11089   1.38347 103.84079
90  560621  1.383063 103.840593
91  560623  1.38268 103.840794
92  560625  1.382201 103.841111
93  560627  1.381864 103.84128
94  560633  1.381204 103.84217
95  560634  1.381582 103.843162
96  560636  1.381192 103.843284
97  560635  1.380788 103.842238
98  560637  1.38034 103.842361
99  560638  1.380486 103.843468
100 560639  1.379957 103.8424
101 560640  1.380024 103.843584

Region11 – sheet 2

Start   End    Distance
11001   11002
11002   11003
11003   11004
11004   11005
11005   11006
11006   11007
11007   11008
11008   11009
11009   11010
11010   11011
11011   11012
11012   11013
11013   11014
11014   11001
11001   11015
11015   11048
11048   11002
11002   11053
11053   11058
11058   11003
11008   11089
11089   11086
11086   11085
11085   11009
11010   11079
11079   11078
11078   11074
11074   11072
11072   11071
11072   11035
11035   11033
11031   11030
11030   11011
11030   11012
11013   11029
11029   11027
11027   11024
11024   11019
11019   11018
11018   11014
11018   11017
11017   11016
11016   11015
11017   11021
11019   11020
11022   11023
11023   11024
11023   11025
11025   11040
11022   11042
11042   11041
11041   11040
11026   11027
11028   11029
11031   11032
11033   11034
11035   11036
11035   11037
11037   11038
11038   11039
11041   11065
11065   11066
11065   11063
11063   11064
11063   11061
11061   11062
11061   11060
11060   11059
11068   11067
11057   11056
11056   11058
11056   11054
11055   11053
11054   11049
11049   11050
11049   11051
11051   11052
11052   11046
11046   11047
11046   11048
11069   11070
11071   11070
11070   11072
11072   11073
11072   11074
11074   11075
11075   11076
11076   11077
11076   11078
11078   11081
11080   11081
11079   11081
11085   11084
11086   11087
11089   11088
11082   11083
560621  11087
11084   560621
11080   560621
11082   560621
11083   560623
560623  11077
560625  11073
560627  11069
560633  11068
560633  11062
560634  11059
560634  11057
560636  11064
560636  11050
560636  11055
560635  11067
560635  11066
560637  11038
560637  11036
560637  11040
560638  11042
560638  11043
560638  11047
560639  11039
560639  11032
560639  11026
560639  11025
560640  11022
560640  11045
560640  11020
560640  11021
560640  560640
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:24:53+00:00Added an answer on June 4, 2026 at 5:24 am

    Your mistake that you refer to the row numbers of the waypoint matrix with the ids of the waypoints. What you really want to do is to find the corresponding row in the waypoints columns that matches to the waypoint id in start or end, respectively.

    You can do this using the ismember-function:

    [~, start] = ismember(N(:,1), M(:, 2));
    [~, to]   = ismember(N(:,2), M(:, 2));
    distance  = distance(M(start,3:4), M(to,3:4));
    

    Note that I also changed your variable name End to to, as end is a special word in MATLAB that I would suggest not to use in variable names. Just differentiating names by their case is potentially faulty.

    Finally, you can write your selection in the distance function using the :-operator in a more compact way, as I have done above.


    Edit 1:

    I feel the need to give a few advices on usual bug tracking strategies. Especially in vector based languages such as MATLAB you are able to write quite complex statements in one line. If this line contains an error, you will have to find a way to tackle that problem down to its root before being able to solve it.

    What I was doing with you in the comments was to try to do exactly that process. Reduce the data step by step and see where the error is happening. Usually, that is something you should be able to do on your own.

    So, let’s get into an example:

    You notice there is a problem in the statement

    deg2km(distance)
    

    There are only two things here that could go wrong. Either you give the wrong input or deg2km is faulty. As deg2km is a function provided by MATLAB, it is highly unlikely (though not impossible) that the error is within that function. Thus, we have to understand what the problem with your input is.

    Now I see a few options that might cause the problem:

    • The datatype of format of the distance variable is completely wrong
    • You need more than one argument
    • There are only problems with a few entries of the distance variable

    To identify the correct one of those options you have to try them systematically. First try:

    deg2km(0.000981522767956357)
    

    That one works. Thus, we are not missing further arguments.

    deg2km([0.000981; 08.9421])
    

    That one works as well. We now know that we may pass a column vector to deg2km without further problems. Now there are only two things left: It is a specific entry in distance that causes trouble or the format of distance is not a column vector.

    Let’s have a try about that: If I understood you correctly, we have distance(1) == 0.000981522767956357. As we know that this number is a valid input of deg2km, we may try the following:

    deg2km(distance(1))
    

    Does that work? If yes, we look further

    deg2km(distance(1:2))
    

    Does that work? If no, we should check what the systematic difference between distance(1:2) and deg2km([0.000981; 08.9421]) is – that is the thing that is likely to cause the error. If it works, however, let’s do

    deg2km(distance(1:20))
    

    What about this one? If that does not work, look into distance(3:20). Something looking strange? You could also try to narrow the problem further down:

    deg2km(distance(1:10))
    

    If that works, we know the problem is located at an entry in distance(11:20). Do that as long as you need until you understood what is causing the problem. Then we should try to understand what causes that input. After that, fixing the problem usually is only a matter of seconds.

    That kind of strategy can be applied to almost all problems you might encounter. It would also have helped you to understand your first problem better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for sure this is not the best title. I'm creating a system to generate
after read this article i tried generate EF model by System.Diagnostics.Process: Process myProcess =
I'm using Windows 7. I've used PHPUnit fine on this system in the past.
in this system I'm currently working on, the DataContext is being generated using SqlMetal
I have this system where a client uploads a logo of a company and
I've been thinking of implementing this system, but can't help but feel there's a
We've got a CMS system written in .NET C#. This system has editing facilities
So I'm getting a prefetch abort exception on our arm9 system. This system does
I'll try my best to explain how I'm trying to set up this system.
I am trying to send a soap message to an external system, this system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.