No BSD License  

Highlights from
Isletter2

Be the first to rate this file! 0 Downloads (last 30 days) File Size: 1.67 KB File ID: #12930

Isletter2

by Jerome Briot

 

08 Nov 2006 (Updated 09 Nov 2006)

Enhancement of the built-in function ISLETTER

| Watch this File

File Information
Description

For a string STR, ISCAPLETTER(STR) returns a vector with 1 for capital letters, -1 for small letters and 0 otherwise.

  ISLETTER2(STR,'all') returns 1 if all components of STR are letters.

  ISLETTER2(STR,'any') returns 1 if any component of STR is a letter.

  Ex:
      str='Matlab R12.1';

      is_isletter=isletter(str);
      is_isletter2=isletter2(str);
      is_isletter2_all=isletter2(str,'all');
      is_isletter2_any=isletter2(str,'any');

      is_isletter =
           1 1 1 1 1 1 0 1 0 0 0 0

      is_isletter2 =
           1 -1 -1 -1 -1 -1 0 1 0 0 0 0

      is_isletter2_all =
           0

      is_isletter2_any =
           1

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
09 Nov 2006 Jos x@y.z

The help can be improved (ISCAPLETTER?, Ex?)

I think:
  q = isletter(str) ;
  q = q - 2*(str==lower(str) & q) ;
is faster then ismember twice.

Why the double tilde (~~)?

Jos

09 Nov 2006 Jérôme Briot

Thanks for the review, Jos.

I corrected the typo in the help and I removed the double tilde.

Your code is more efficient than mine.

Jérôme

Please login to add a comment or rating.
Updates
09 Nov 2006

Minor modification to avoid one M-lint warning.

09 Nov 2006

Correction after review by Jos

09 Nov 2006

Complete modification from the review by Jos

Tag Activity for this File
Tag Applied By Date/Time
strings Jerome Briot 22 Oct 2008 08:48:23
isletter capital small letter Jerome Briot 22 Oct 2008 08:48:23

Contact us at files@mathworks.com