Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

counting the number of words in a string

8 views
Skip to first unread message

shantanu thakar

unread,
May 24, 2012, 10:29:16 AM5/24/12
to

is there any function for counting the number of words in a string?
or rather which function will be the easiest to impliment in the counting

eg: the string is: 'Name PMT1 PMT2 Load Speed Add1 Add2'
where the space in between can be tabs or spaces.

thank you

John D'Errico

unread,
May 24, 2012, 10:57:07 AM5/24/12
to
"shantanu thakar" <shantan...@gmail.com> wrote in message <jplgjs$4v1$1...@newscl01ah.mathworks.com>...
I posted allwords on the file exchange long ago.

http://www.mathworks.com/matlabcentral/fileexchange/27184-allwords

>> allwords('Name PMT1 PMT2 Load Speed Add1 Add2')
ans =
'Name' 'PMT1' 'PMT2' 'Load' 'Speed' 'Add1' 'Add2'

John

reza

unread,
May 24, 2012, 2:43:51 PM5/24/12
to
On May 24, 10:29 am, "shantanu thakar" <shantanutha...@gmail.com>
wrote:
you can also use regexp as follows:

>> regexp('Name PMT1 PMT2 Load Speed Add1 Add2' , '\t+| +', 'split')
ans =

'Name' 'PMT1' 'PMT2' 'Load' 'Speed' 'Add1'
'Add2'

/reza

Bruno Luong

unread,
May 24, 2012, 3:16:07 PM5/24/12
to

reza

unread,
May 24, 2012, 3:20:06 PM5/24/12
to
On May 24, 3:16 pm, "Bruno Luong" <b.lu...@fogale.findmycountry>
wrote:
> Attn to reza:
>
> here is how your posts lookhttp://www.mathworks.com/matlabcentral/newsreader/view_thread/320397#...
>
> Bruno

Interesting! Not sure what to do about it though. I am posting
through GoogleGroups and looks ok on Google:

http://groups.google.com/group/comp.soft-sys.matlab/browse_thread/thread/8445bba53af633d8/7dedf3dcef559f9b?hl=en&q=#7dedf3dcef559f9b

/reza

Nasser M. Abbasi

unread,
May 24, 2012, 3:29:00 PM5/24/12
to
I think you found a bug in Mathworks newsreader interface !

I see Reza's post just fine using thunderbird newsreader on my PC

screen shot

http://12000.org/tmp/052412/post.png

--Nasser

Bruno Luong

unread,
May 24, 2012, 3:35:16 PM5/24/12
to
"Nasser M. Abbasi" <n...@12000.org> wrote in message <jpm260$lr2$1...@speranza.aioe.org>...

>
> I think you found a bug in Mathworks newsreader interface !

I don't know if it's TMW, or google, or both. I warned ImageAnalyst, Greg, and now Reza.

May be if Helen read this she can try to locate where is the problem.

Bruno

james bejon

unread,
May 24, 2012, 4:13:15 PM5/24/12
to
"shantanu thakar" <shantan...@gmail.com> wrote in message <jplgjs$4v1$1...@newscl01ah.mathworks.com>...
>
s = 'Name PMT1 PMT2 Load Speed Add1 Add2';
n = length(regexp(s, '\s+'))+1;
0 new messages