MATLAB: Index in position 1 exceeds array bound (must not exceed 2) error

array boundindex position errormatrixtimer

>> x=rand(5,5)
x =
0.8594 0.8865 0.7127 0.0424 0.8175
0.8055 0.0287 0.5005 0.0714 0.7224
0.5767 0.4899 0.4711 0.5216 0.1499
0.1829 0.1679 0.0596 0.0967 0.6596
0.2399 0.9787 0.6820 0.8181 0.5186
>> t=timer('timerfcn',@(x,y)disp(x(2,2)))
t =
Timer Object: timer-6
Timer Settings
ExecutionMode: singleShot
Period: 1
BusyMode: drop
Running: off
Callbacks
TimerFcn: @(x,y)disp(x(2,2))
ErrorFcn: ''
StartFcn: ''
StopFcn: ''
>> start(t)
Error while evaluating TimerFcn for timer 'timer-6'
Index in position 1 exceeds array bounds (must not exceed 1).

Best Answer

t=timer('timerfcn',@(x,y)disp(x(2,2)) this line is incorrect ,it should have been t=timer('timerfcn',@(x1,y)disp(x(2,2)) instead.
Related Question