How to delete the colon's in a matrix?

1 vue (au cours des 30 derniers jours)
bilgesu ak
bilgesu ak le 9 Mar 2016
Commenté : bilgesu ak le 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 commentaires
Stephen23
Stephen23 le 9 Mar 2016
Modifié(e) : Stephen23 le 9 Mar 2016
Why not just find-and-replace using any text editor?
bilgesu ak
bilgesu ak le 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...

Connectez-vous pour commenter.

Réponses (2)

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

Connectez-vous pour commenter.


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

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by