0

I have a cell array that contains string.

Those individual string needs to be processed, like for example:

 a  = {'1,2','12';'2,3','23'}

in which, comma should be removed from the string.

I don't know if what's the speed of using for loop compared with using vectorization.

But how can I achieve that using vectorization?

1 Answer 1

6

You can use strrep to replace characters in a string, like this:

EDU>> a = {'1,2','12';'2,3','23'}
a = 
    '1,2'    '12'
    '2,3'    '23'
EDU>> strrep(a,',','')
ans = 
    '12'    '12'
    '23'    '23'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.