Import single raws from excel using the find function.
1 view (last 30 days)
Show older comments
Hi, I have an assignment where the user should type a year, and the program should return the winner of the Eurovision Song Contest that year, with the song and country ect. All of this data is stored in a excel worksheet, and the interesting information from a specific year is stated on one raw. for example
1958 Nederland Frankrike "Dors, mon amour" André Claveau
1959 Nederland Frankrike "Dors, mon amour" André Claveau
1960 Nederland Frankrike "Dors, mon amour" André Claveau
First I'll imported the data:
[~, ~, raw] = xlsread('ESCvinnere-2','A1:E64');
[~, ~, Vertsland] = xlsread('ESCvinnere-2','B2:B64');
[~, ~, Sang] = xlsread('ESCvinnere-2','D2:D64');
[~, ~, Vinner] = xlsread('ESCvinnere-2','C2:C64');
[~, ~, Bandartist] = xlsread('ESCvinnere-2','E1:E64');
[~, ~, aar] = xlsread('ESCvinnere-2','A1:A64');
And I'll use the input command to let the user type in a number for the year. I then don't understand how I can let the find function import the current raw from the worksheet to the command window.
0 Comments
Answers (2)
Thorsten
on 1 Oct 2015
Edited: Thorsten
on 1 Oct 2015
You should use the first return values from xlsread to read numberical data, such as
year = xlsread('ESCvinnere-2','A1:E64');
and the second value to read text data, such as
[~, Vertsland] = xlsread('ESCvinnere-2','B2:B64');
Then you can find the index for year y (given by user) as
idx = find(year == y);
And then use this index to address the other values
Vertsland{idx}
If this is not what you want, it would be helpful to upload the xlsfile.
Frank Larsen Klippenberg
on 1 Oct 2015
2 Comments
Emil Roaldsoy
on 2 Oct 2015
What codes did you use for making the program? Im still a little bit off atm.
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!