Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Is there a way, when reading a file to insert text between a deliminator.

1 回表示 (過去 30 日間)
Kathleen
Kathleen 2014 年 8 月 22 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
My file has a header line that looks like this
[Column a, Column b, column c, colunm d;]
and then following rows with information like this
[1,1,,1;1,1,,1;1,1,,1]
I've been using the strtok function to separate the values but since there is no character between the commas in the third column, it doesn't recognize it as anything and shifts all my information over one column. Is there a way to insert a value into that column.

回答 (1 件)

AJ von Alt
AJ von Alt 2014 年 8 月 22 日
Use strsplit with "Collapse Delimiters" disabled.
inputstr = '[1,1,,1;1,1,,1;1,1,,1]';
C = strsplit( inputstr , ',' , 'CollapseDelimiters' , 0 );
C =
'[1' '1' '' '1;1' '1' '' '1;1' '1' '' '1]'

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by