[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Importing data problems
From: |
martin_helm |
Subject: |
RE: Importing data problems |
Date: |
Wed, 30 Sep 2009 09:13:33 -0700 (PDT) |
s4y wrote:
>
> Hey, thanks for your attempt. It helped alot.
> I got my programme almost workin so far. But i have one problem.
> My programme:
> [fid] = fopen("test2.txt", "r", "native");
> kopfzeile = fgetl(fid);
> [m, count] = fscanf(fid, "%f:%f:%f %f %f %f %f %f %f",[2,9]);
> fclose(fid);
> m
>
> the file test2.txt:
> Text
> 16:09:06 32.41 32.63 36.43 36.63 36.65 34.56
> 16:09:13 32.39 35.63 46.43 66.83 26.65 34.56
>
> Unfortunately he saves the matrix m this way:
> 16 06 32.63 36.63 34.56 09 32.39
> 09 32.41 36.43 36.65 16 13 35.63
>
> he starts to write it in the first column and then he is moving on to next
> column
> but i need it this way:
> 16 09 06 32.41 32.63 36.43 36.63 36.65 34.56
> 16 09 13 32.39 35.63 46.43 66.83 26.65 34.56
> like in the file, line by line
> But i dont know how to change this.
> Hopefully someone knows a way.
> Thanks in advance.
>
>
You can use
[fid] = fopen("test2.txt", "r", "native");
kopfzeile = fgetl(fid);
[m, count] = fscanf(fid, "%f:%f:%f %f %f %f %f %f %f",[9,2]);
m=m';
fclose(fid);
But it has still the drawback that you have to know the number of lines in
advance.
Instead you can do something like
[fid] = fopen("test2.txt", "r", "native");
kopfzeile = fgetl(fid);
[m, count] = fscanf(fid, "%f:%f:%f %f %f %f %f %f %f");
fclose(fid);
m = reshape(m, 9, count/9)';
Regards
Martin
--
View this message in context:
http://www.nabble.com/Importing-data-problems-tp25659793p25684266.html
Sent from the Octave - General mailing list archive at Nabble.com.