How to delete the colon's in a matrix?

6 visualizzazioni (ultimi 30 giorni)
bilgesu ak
bilgesu ak il 9 Mar 2016
Commentato: bilgesu ak il 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 Commenti
Stephen23
Stephen23 il 9 Mar 2016
Modificato: Stephen23 il 9 Mar 2016
Why not just find-and-replace using any text editor?
bilgesu ak
bilgesu ak il 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...

Accedi per commentare.

Risposte (2)

Walter Roberson
Walter Roberson il 9 Mar 2016
If you have strings or a cell array of strings, you could use
regexp(TheData, ':', ',')
  1 Commento
bilgesu ak
bilgesu ak il 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
....]

Accedi per commentare.


Jos (10584)
Jos (10584) il 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,':',',')

Community Treasure Hunt

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

Start Hunting!

Translated by