File formatting in Matlab

1 view (last 30 days)
Arijit Mondal
Arijit Mondal on 13 Dec 2018
Edited: Stephen23 on 13 Dec 2018
Hi ,
I have a text file which has numerical data in the following format:
582 120
-116 -338
534 520
-279 -351
-423 428
581 502
581 -41
-134 277
131 -603
352 -432
181 590
110 -606
-44 429
504 -288
-123 -49
511 186
190 -514
510 541
29 -268
-502 502
-29 -366
439 115
350 425
603 582
-362 -47
-111 -367
I wan to edit the file such that I get the data in the following format:
582
120
-116
-338
534
520
-279
-351
-423
428
581
502
581
-41
-134
277
131
-603
352
-432
181
590
110
-606
-44
429
504
-288
-123
-49
511
186
190
-514
510
541
29
-268
-502
502
-29
-366
439
115
350
425
603
582
-362
-47
-111
-367
Any adcice on how to do this in matlab?

Answers (1)

Stephen23
Stephen23 on 13 Dec 2018
Edited: Stephen23 on 13 Dec 2018
>> M = dlmread('temp0.txt');
>> M = M.';
>> dlmwrite('temp1.txt',M(:))
The test files are attached.

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!