Illegal use of reserved keyword "else"

7 views (last 30 days)
Eleonora Ceccaldi
Eleonora Ceccaldi on 15 Nov 2019
Commented: dpb on 18 Nov 2019
Hello everyone.
I'm running a code and I get the aforementioned error for the following part:
% process ratings
formatSpec = '%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n';
ratings_matrix = fscanf(fileID, formatSpec, ratings_matrix_size);
if (size(ratings_matrix, 2) > 0)
% check for honeypot question
hp = (ratings_matrix(end,:) == 2 | ratings_matrix(end,:) == 3 | ratings_matrix(end,:) == 4);
if (sum(hp) ~= 0)
disp("Warning: honey-pot check failed.");
index = find(hp, 1);
number_of_dropped_ratings = number_of_dropped_ratings + (size(ratings_matrix, 2) - index + 1);
ratings_matrix = ratings_matrix(:, 1 : index - 1);
number_of_failed_checks = number_of_failed_checks + 1;
end
participant_id_vector = k * ones(1, size(ratings_matrix, 2));
ratings = [ratings; [participant_id_vector; ratings_matrix(3:end,:)]'];
number_of_participants = number_of_participants + 1;
else
nationality(k) = "NULL";
study_level(k) = "NULL";
gender(k) = -1;
age(k) = -1;
end
The error apperas to be in the last else statement but I can't figure out what's wrong. Thank you for your help!
  9 Comments
Eleonora Ceccaldi
Eleonora Ceccaldi on 18 Nov 2019
It turns out the problem was with the file name! Thanks a lot
dpb
dpb on 18 Nov 2019
I like the analogy, Steven! :) Will have to remember that for future.

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!