tags:

views:

66

answers:

2

I need to open a text file and convert it into a CSV file in Matlab. The first 3 lines of the text file are sentences that need to be omitted. The next 28 lines are numbers that need to make up the first column of the CSV, and then the next 28 lines need to make up the second column.

The text file is called datanal.txt and the output file can be named anything. Any help would be appreciated.

A: 

well you can add #'s in front of the first 3 lines then use load and a reshape. Did you need a fully automated script or is there only one file? If you're familiar with matlab at all there are a bunch of ways to turn that large column vector into a matrix.

Chris H
+2  A: 

Don't have Matlab now to test, but try this. Your input file should be in Matlab's current directory, or put the full path to the file name.

A = csvread('datanal.txt',3,0);
A = reshape(A,28,2);
csvwrite('output.csv',A)
yuk

related questions