|
"sushma sharma" <ssharma@ynospamahoo.com> wrote in message
<fp7a1d$db4$1@fred.mathworks.com>...
> hi,
>
> i have a cell array of strings, a =
>
> '1'
> '9'
> '12'
> '1/10'
> '1/10'
>
> how can i delimit on '/', so that if there is a '/' in the
> string i get the elements to teh right of the '/', and if
> there is no '/', i get the element as it is.
>
> the output would be
>
> 1
> 9
> 12
> 1
> 1
>
> so far i've tried strfind(a,'/') and haven't made much progress.
>
> any help would be appreciated!
>
> thank you once again!
>
> sushma
>> [s,r] = strtok(str, '/');
splits the string 'str' into two parts. The part before the '/' appears in 's', the
part after in 'r' - the remainder.
Maybe this can help? You can test if r is empty
if isempty(r)
ret = str;
else
ret = r;
end
|