필터 지우기
필터 지우기

how can I filter the nth character from categorical?

조회 수: 2 (최근 30일)
Aletta Wilbrink
Aletta Wilbrink 2018년 3월 19일
답변: Peter Perkins 2018년 3월 23일
i have a categorical value a, looks like:
a = 888-2018-02160001
Now I want the 10th and 11th character, the '02'.
I already tried a(10:11), but that doesn't work, because the length of a is 1. Also when I try string(a), the length is still 1
How can I filter these characters from a categorical?

채택된 답변

Birdman
Birdman 2018년 3월 19일
>>a = '888-2018-02160001'
a(10:11)
ans =
'02'
  댓글 수: 3
Birdman
Birdman 2018년 3월 19일
편집: Birdman 2018년 3월 19일
What does your variable look like? If it is in string form, then simply convert them to char by typing
char(a)
and then extract 10th and 11th characters at all rows as
a(:,10:11)
Aletta Wilbrink
Aletta Wilbrink 2018년 3월 19일
That works, thanks!

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

추가 답변 (1개)

Peter Perkins
Peter Perkins 2018년 3월 23일
If you have a categorical variable, as in the categorical data type, then it sounds like you want to work with the category names. Converting the entire (large) categorical array will be very inefficient in terms of memory. probably the easiest thing to do is to make a copy, modify the copy's category names using renamecats, and you're done.
Not enough information to go to know if that's what you want.

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by