excel make rows equal
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
above there is a file called kilos.xls
in matlab I want to use readtable to load in the data then I want the user to use a menu to select a state then I want to print the number of fans and the percentage of people who lose interest into the command window for example if in the menu I choose texas I want to output in the state texas there are 400 fans and 45% of peope lose interest in the command window
I know how to use the readtable and menu function but what I need help with is when I select an option from state how do I print the other numbers in the command window
0 commentaires
Réponses (1)
Pratheek Punchathody
le 23 Nov 2020
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!