Can someone help me with this?

I want to separate the word for the string vector by using loop. For example I have a str= 'hello,my,word' Then I want my result to be by using loop, so I can using index to call such as below: word(1)=hello word(2) = my word(3) = word I want to make it work in general case too. Can someone help me with this? Thank you

 Accepted Answer

First, read this:
help strfun
Look at the functions you will find there. Read the help for those that might seem to be of use.
str= 'hello,my,word'
str =
'hello,my,word'
strsplit(str,',')
ans =
1×3 cell array
{'hello'} {'my'} {'word'}

Categories

Community Treasure Hunt

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

Start Hunting!