Why did I get this error? Array indices must be positive integers or logical values. I copied and pasted MATLAB sample code

1 view (last 30 days)
Array indices must be positive integers or logical values.
Error in eyeMovement (line 30) latest_gaze_data = gaze_data(end);
I copied and pasted exact same sample code from MATLAB: http://developer.tobiipro.com/matlab/matlab-step-by-step-guide.html
Even if I change it to gaze_data(0); or gaze_data(1); still same error.

Answers (2)

Image Analyst
Image Analyst on 23 Jun 2018
I'd recommend you read that section of the FAQ: https://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F for a really good explanation. Then read the rest of the FAQ for more good info that will help you later.

Star Strider
Star Strider on 23 Jun 2018
Check to see what ‘gaze_data’ is in your workspace:
S = whos('gaze_data')

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!