How to solve this error index in position 1 exceeds array bounds?
19 views (last 30 days)
Show older comments
Nisar Ahmed
on 26 Jan 2022
Commented: Cris LaPierre
on 26 Jan 2022
Hi,
How I can correct this error?
Index in position 1 exceeds array bounds (must not exceed 128).
Error in Create_Obs_dataL (line 60)
synth = synth(1+t0_i:nt+t0_i,:);
0 Comments
Accepted Answer
Cris LaPierre
on 26 Jan 2022
The error is that your indexing of rows (specifically nt+t0_i), is resulting in a number higher that the total number of rows in your matrix. Here's a simple example:
A = rand(2,1)
% Works
A(2,1)
% Your error
A(3,1)
6 Comments
Cris LaPierre
on 26 Jan 2022
nt = 115;
f0 = 50;
t0 = 2/f0;
dt = 0.001;
t0_i = floor(t0/dt)
nt+t0_i
Apparently your matrix has 128 rows, and you are trying to access the 155th, hence the error. Your equation does not appear to scale correctly with nt. You need to figure out what the correct value should be, and adjust your math accordingly.
More Answers (0)
See Also
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!