searching variable names from a table, apply to matrix

3 views (last 30 days)
Hello, I thought I had this solved but Ive got another hiccup. I have a very large data set that has been cleaned down to a name, an age, and a score. The names are coded and have numbers, dots, spaces, letters, etc. I need to combine many spread sheets to add the score together. Ultimately I will have one table with a name followed by each score collected over an age range. Here is what a snippit of the data looks like:
'0400-4' 1978 310
'0400-5' 1978 315
'0400-6' 1985 554
'0403-1' 1997 145
'0403-2' 1999 334
'0403-3' 1987 165
'0403-4' 1964 186
'0405-100' 1985 645
So I intended to create a loop that starts with table 1, then it opens a new spreadsheet, and if the name matches the name found in the second spread sheet it enters the next value adjacent. spreadsheet 2 might look like this:
'0400-4' 1980 302
'0400-5' 1980 302
'0400-600A' 1987 502
'0403-1' 1999 101
'0403-2' 2001 312
'0403-3' 1989 118
'0405-100' 1987 601
And I want to end up with something like this; (knowing that the year value is missing, I will deal with that later.)
'0400-4' 310 302
'0400-5' 310 302
'0400-6' 554 NaN
'0403-1' 145 145
'0403-2' 334 101
'0403-3' 165 11
'0403-4' 186 NaN
'0405-100' 645 601
I played around with opts = detectImportOptions("CO01.xlsx"); and opts.SelectedVariableNames but couldn't really get anything to work. the problems seem to be tons of gaps in the data, lots of NaN's, mising info, etc, which is the reason I was trending towards a loop. I only care to pull out the continuous data. Thanks in advance for any suggestions

Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!