Hi Abdul
I have imported the data from the file kilos.xlsx. Using the "readtable()" the data is imported into the workspace. With the "height()" function the total number of rows is calculated.
Please use the following code to get the name of the state as an input from the user and display the totalNumberOfFans and peopleWhoLoseInterestInTheSport with respect to the entered state by the user.
x = readtable(' kilos.xlsx'); %import the table to the workspace
h = height(x); %calculate the number of rows in the table
prompt = "Enter the state"; %Prompt message in the workspace
str = input(prompt,'s'); %Request user input
for i=1:h %logic to iterate through the rows of the table
t = strcmp(str,x.state(i)); %compare strings and get logical output
if(t==1)
disp(x(i,:)); %Display the respective row as an output
break;
end
end
Refer to the documentation of Request user input for further information. Also refer to strcmp() if you need more information on comparing strings.
Hope this helps.