choose string variables using ismember

Hi all,
I have the column
A=
'0'
'0'
'uk'l1'
'ukl1'
'ukl1'
'ukl1'
'ukl2'
'ukl2'
'0'
'0'
'Grl1'
'Grl1'
'Grl1'
'ukl1'
'Grl2'
'Grl3'
'Grl4'
' 0'
'Gerl1'
'Gerl1'
'Gerl2'
'Gerl3'
'Gerl4'
i want using the command similar to the below one
ismember(A,{'} )
to choose all the elements of A apart from zero. so it should be something like
ismember(A,{'ukl1' 'ukl2' 'ukl3' 'ukl4' 'ukl5' and so forth ...) )
but the problem is that A in my daraset is 8000 by 1 and contains many string variables (ukl1, ukl2,...,) so it would be very tiring to write by hand all these string variables into ismember. I would also like to mention that for example the first two letters of say, 'ukl1'denote the country (uk) and the last two the location (location 1, location 2, location3,...) thanks

댓글 수: 2

antonet
antonet 2012년 5월 23일
i think it should be ismember(A,unique(A) ) but i need to exclude 0
Oleg Komarov
Oleg Komarov 2012년 5월 23일
Do you want to exclude ' 0' too?

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

 채택된 답변

Oleg Komarov
Oleg Komarov 2012년 5월 23일

0 개 추천

setdiff(A,'0')

댓글 수: 3

antonet
antonet 2012년 5월 23일
tahnk you.where should i put this command. inside ismember or before it?
Oleg Komarov
Oleg Komarov 2012년 5월 23일
You dont need ismember.
antonet
antonet 2012년 5월 23일
thanks!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

태그

질문:

2012년 5월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by