Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

2 Ansichten (letzte 30 Tage)
Kathleen
Kathleen am 22 Aug. 2014
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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.

Antworten (1)

AJ von Alt
AJ von Alt am 22 Aug. 2014
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]'

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by