How to delete the colon's in a matrix?

1 view (last 30 days)
bilgesu ak
bilgesu ak on 9 Mar 2016
Commented: bilgesu ak on 9 Mar 2016
Hi;
I have a data in the form of :
1,2:8
1,3:3
1,4:3
1,5:2
1,6:5
Is there an easy way to remove the colons and have the form below?
1,2,8
1,3,3
1,4,3
1,5,2
1,6,5
I have many many rows like that and I am looking for a quick way if possible...
Regards...
  2 Comments
Stephen23
Stephen23 on 9 Mar 2016
Edited: Stephen23 on 9 Mar 2016
Why not just find-and-replace using any text editor?
bilgesu ak
bilgesu ak on 9 Mar 2016
Thanks very much. Sometimes I try to solve everything in Matlab... I correct it in a Word file and paste to the m.file...
Thank you very much!!
Regards...

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 9 Mar 2016
If you have strings or a cell array of strings, you could use
regexp(TheData, ':', ',')
  1 Comment
bilgesu ak
bilgesu ak on 9 Mar 2016
I have the data only. when I paste it to th m.file it is shown as I wrote before.. How can I convert it to strings? I want to have a matrix at the end like:
[1,2,8
1,3,3
1,4,3
....]

Sign in to comment.


Jos (10584)
Jos (10584) on 9 Mar 2016
Is the data stored as strings in a cell array?
C = {'1,6:3','2,5:3','99,103:4'}
C2 = strrep(C,':',',')

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!