I have a data file which looks like this:
-4.999492 -0.569242 -0.681710 -4.999759 -0.805206 -0.491153 -5.349476 -0.566062 -0.4709开发者_开发问答35
-4.999759 -0.805206 0.491153 -4.906714 -0.686502 0.620194 -4.999492 -0.569242 0.681710
-5.349476 -0.566062 -0.470935 -5.299752 -0.811038 -0.147914 -5.568033 -0.568687 -0.119200
-4.999492 -0.569242 -0.681710 -4.906714 -0.686502 -0.620194 -4.999759 -0.805206 -0.491153
-5.299752 -0.811038 -0.147914 -5.349476 -0.566062 -0.470935 -4.999759 -0.805206 -0.491153
-5.568033 -0.568687 0.119200 -5.568033 -0.568687 -0.119200 -5.299752 -0.811038 -0.147914
This is just a small sample. Altogether there are 9 columns and about 1000 rows. I need to import this data into a 2D matlab file, where each cell is storing just one number.
How can I do this ?
The fscanf
function will probably do what you want.
You may try the import wizard which does generate the import code when requested.
There are quite a few possibilities actually,
M = load( 'data.txt', '-ascii' );
M = dlmread( 'data.txt', ' ');
And some more functions that can handle more complicated formats.
精彩评论