Uppercase string from the cell array

조회 수: 8 (최근 30일)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015년 8월 12일
편집: Stephen23 2015년 8월 12일
I have a cell array a = {'AA_DFA_DD' ,'DSFA_dfaf' ,'DDDD' , 'DFE1' ,'dfs_DD'}
How can extract only the upper case string from the cell array
my answer should be {'AA_DFA_DD',[],'DDDD','DFE1',[]}
How can i do this?
Thanks a lot
  댓글 수: 1
Stephen23
Stephen23 2015년 8월 12일
+1 for a clear question with input and output examples.

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

채택된 답변

Stephen23
Stephen23 2015년 8월 12일
편집: Stephen23 2015년 8월 12일
regexp(a,'^[^a-z]+$','match')
  댓글 수: 2
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015년 8월 12일
편집: Stephen23 2015년 8월 12일
It works well
Can give me the small explanation of expression
Thanks a lot
Stephen23
Stephen23 2015년 8월 12일
편집: Stephen23 2015년 8월 12일
^ % match start of string
[^a-z] % match any character EXCLUDING lower-case
+ % repeated one or more times
$ % match end of string
These are all explained in the documentation:

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 8월 12일
편집: Azzi Abdelmalek 2015년 8월 12일
out=a(cellfun(@(x,y) isequal(x,y),a,upper(a)))
or
out=cell(size(a))
idx=cellfun(@(x,y) isequal(x,y),a,upper(a))
out(idx)=a(idx)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by