How to delete the colon's in a matrix?

2 ビュー (過去 30 日間)
bilgesu ak
bilgesu ak 2016 年 3 月 9 日
コメント済み: bilgesu ak 2016 年 3 月 9 日
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 件のコメント
Stephen23
Stephen23 2016 年 3 月 9 日
編集済み: Stephen23 2016 年 3 月 9 日
Why not just find-and-replace using any text editor?
bilgesu ak
bilgesu ak 2016 年 3 月 9 日
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...

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 3 月 9 日
If you have strings or a cell array of strings, you could use
regexp(TheData, ':', ',')
  1 件のコメント
bilgesu ak
bilgesu ak 2016 年 3 月 9 日
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
....]

サインインしてコメントする。


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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by