필터 지우기
필터 지우기

Using intersect to assign a classification

조회 수: 1 (최근 30일)
Kate
Kate 2013년 6월 4일
Hi there!
I've created a classification matrix and have used intersect to find the common cell, but the problem is that I want the information in the cell next to it.
Example:
US-Goo US-Ha1 US-Ha2
GRA DBF ENF
What I have:
a=length(landclass)
IGBPclass=intersect(sitename, landclass)
IGBPclass='US-Ha1'
Ideally I want IGBPclass to be the second 3 letter classification.
Thanks!
  댓글 수: 2
Matt J
Matt J 2013년 6월 4일
편집: Matt J 2013년 6월 4일
Show us sitename and landclass. Show the result you are getting. Show the result that you want. Why do you overwrite IGBPclass in the 3rd line of code,
IGBPclass='US-Ha1'
Kate
Kate 2013년 6월 5일
The sitename is US-Ha1
The landclass that encapsulates this site is DBF.
I would like the IGBPclass to be DBF, not US-Ha1.
The third line is the output of the intersect function.
I've tried the 'rows' syntax in an attempt to grab the matching data, but get this error message.
"Warning: The 'rows' input is not supported for cell array inputs. > In cell.intersect>cellintersectlegacy at 154 In cell.intersect at 143 "
Thanks for your help!

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

채택된 답변

Matt J
Matt J 2013년 6월 5일
편집: Matt J 2013년 6월 5일
The third line is the output of the intersect function.
That's very confusing since we cannot distinguish it from other lines of code. This is how you should show contents of variables to the public,
>> landclass, sitename
landclass =
'US-Goo' 'US-Ha1' 'US-Ha2'
'GRA' 'DBF' 'ENF'
sitename =
US-Ha1
If the above is the form your data is in, I suspect you are trying to do this:
>> logicalIndex=ismember(landclass(1,:),sitename);
>> IGBPclass=landclass{2,logicalIndex}
IGBPclass =
DBF
  댓글 수: 1
Kate
Kate 2013년 6월 5일
That worked. Thank you for your help and sorry for being confusing.

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

추가 답변 (1개)

the cyclist
the cyclist 2013년 6월 5일
I don't fully understand what you are trying to do. However, if you read
doc intersect
you will see that you can call that command with more than one output. The second and third outputs are the indices for the elements that are in the intersection of the two sets. Maybe you can use those indices to do what you want.

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by