How to have Matlab find row on excel and display the corresponding excel row?

2 views (last 30 days)
Hello,
I have a code where it prompts you to type in a year, and it is supposed to return the horse/trainer/owner on the corresponding row in a separate excel file (that contains all of the information). I want to have Matlab find the row that contains the number and then display the information in the following columns. I cannot figure this out, here is my code so far.
Q = xlsread('KentuckyDerbyStats');
prompt = 'Please pick a year between 1950 and 2017 ';
x = Q(:,1);
year = input('Please pick a year between 1950 and 2017 ');
true = (x == year);
answer = Q(true,:)
  1 Comment
Walter Roberson
Walter Roberson on 26 Feb 2018
That code looks like it would work. However, it is not recommended to use true or false as variable names, as they are needed to represent logical values; at the very least you are going to confuse people who read the code.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!