merging two structures using join()

I've imported two xlsx files via importdata() and I'm trying to merge them with join() using a common key 'PitID'. The imported structures each contain data, textdata, and colheaders objects. In my case all colheaders are variable names, while data and textdata contain their respective values.
Help?
>> pits = importdata('E:\Sedgwick\Data\GPS\pits.xlsx') field = importdata('E:\Sedgwick\Data\Field\field.xlsx')
pits =
data: [99x7 double]
textdata: {100x7 cell}
colheaders: {'Latitude' 'Longitude' 'Pit_ID' 'GPS_Height' 'Datafile' 'GPS_Date' 'samp_status'}
field =
data: [12x22 double]
textdata: {13x22 cell}
colheaders: {1x22 cell}
>> %% Confirm structure headers pits.colheaders field.colheaders
ans =
'Latitude' 'Longitude' 'Pit_ID' 'GPS_Height' 'Datafile' 'GPS_Date' 'samp_status'
ans =
Columns 1 through 10
'PitID' 'labID' 'date' 'hor_top' 'hor_bot' 'genetic' 'primgen' 'subgen' 'colortype' 'hue'
Columns 11 through 20
'value' 'chroma' 'grade' 'size' 'type' '2grade' '2size' '2type' 'rootquan' 'rootsize'
Columns 21 through 22
'roottype' 'co2'
>> data = join(pits,field,'PitID'); Undefined function 'join' for input arguments of type 'struct'.

 채택된 답변

Jan
Jan 2013년 2월 20일
편집: Jan 2013년 2월 20일

0 개 추천

Do you mean join, which is part of the Statistics Toolbox and operates on dataset arrays?

댓글 수: 3

Sam
Sam 2013년 2월 21일
Hi Jan, I think you're implying that the structure conferred by importdata() is not a dataset array and thus can't be used with join()? That makes sense, but my aim is to combine a dataset of spatial points with two datasets of attributes such that the attribute names are passed into the output as headers - or at least as the first row in the output.
Do you know of another way to do this? Perhaps using a different import function, or a merge function compatible with the importdata() structure?
Jan
Jan 2013년 2월 21일
You can use the dataset command to import data from an XLSX file also, and then join works.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

Sam
2013년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by