I'm encountering the following error when I run my main program.

Index in position 2 exceeds array bounds. Index must not exceed 1440.
Error in topo_mask
data = topo(xmin:xmax, ymin:ymax);
^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in Main_program
mask=topo_mask(main_path,area,rslt,mask_depth);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 Accepted Answer

Do you see the problem ?
a = rand(4,5)
a = 4×5
0.8078 0.4142 0.9365 0.4319 0.4061 0.4331 0.0943 0.7995 0.2306 0.9260 0.0461 0.7000 0.8302 0.2652 0.4430 0.9862 0.6140 0.5213 0.8581 0.2236
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
a(1:3,4:6)
Index in position 2 exceeds array bounds. Index must not exceed 5.
"ymax" is bigger than the second dimension of the array "topo", namely 1440.

More Answers (0)

Products

Release

R2024b

Asked:

on 7 Sep 2025

Edited:

on 7 Sep 2025

Community Treasure Hunt

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

Start Hunting!