Continue Long Statements on Multiple Lines
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I would be thankful if one can help me solve this issue.
I have a .txt file with a large number of lines (i.e 87471) .
A snapshot is as follows.
Sys_7899 1=0.21 2=0.31 3=0.32 4=0.77 5=0.97 6=0.1 7=0.31 8=0.71
9=0.92 10=0.36 11=0 13=0.147 14=0.55
Sys_7900 1=0.41 2=0.53 3=0.80 4=0.69 5=0.34 6=0.94 7=0.1 8=0.48
9=0 10=0.4 11=0 12=0.21
Sys_7901 1=0.41 2=0.53 3=0.84 4=0.69 5=0.34 6=0.94 7=0.11
Sys_7902 1=0.56 2=0.13 3=0.89 4=0.11 5=0.11 6=0.12 7=0.17
In fact, the no. of samples are not the same (in each col.)
How can I add the second lines to the end of the first lines when the no. of samples goes more 8? In fact, I want to have all samples in just one and not given them into two lines for each sys like.
Sys_7900 1=0.41 2=0.53 3=0.80 4=0.69 5=0.34 6=0.94 7=0.1 8=0.48 9=0 10=0.4 11=0 12=0.21
0 Kommentare
Antworten (1)
dpb
am 11 Dez. 2020
ix=find(~contains(txt,'Sys'));
>> arrayfun(@(ix) join(txt(ix-1:ix),1),ix)
ans =
2×1 cell array
{'Sys_7899 1=0.21 2=0.31 3=0.32 4=0.77 5=0.97 6=0.1 7=0.31 8=0.71 9=0.92 10=0.36 11=0 13=0.147 14=0.55'}
{'Sys_7900 1=0.41 2=0.53 3=0.80 4=0.69 5=0.34 6=0.94 7=0.1 8=0.48 9=0 10=0.4 11=0 12=0.21' }
>>
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dynamic System Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!