How to solve this error index in position 1 exceeds array bounds?

조회 수: 17 (최근 30일)
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,:);

채택된 답변

Cris LaPierre
Cris LaPierre 2022년 1월 26일
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)
A = 2×1
0.8538 0.6416
% Works
A(2,1)
ans = 0.6416
% Your error
A(3,1)
Index in position 1 exceeds array bounds. Index must not exceed 2.
  댓글 수: 6
Nisar Ahmed
Nisar Ahmed 2022년 1월 26일
actuall, when my data point was nt = 260, it is working well. but as in new data points nt = 115, it started giving error
Cris LaPierre
Cris LaPierre 2022년 1월 26일
nt = 115;
f0 = 50;
t0 = 2/f0;
dt = 0.001;
t0_i = floor(t0/dt)
t0_i = 40
nt+t0_i
ans = 155
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by