English 中文(简体)
Matlab 文件阅读
原标题:Matlab File Reading

我的档案有许多数据点,所有格式都如XX.XXX。 这些数字是不断加固的。

我如何把所有数字单独区分为个人价值?

我尝试从档案中读取的比例为5.3和%5.3f,但两者均未奏效。 同样,6%的人没有工作。

Example Input:

75.91425.43937.55492.55874.43839.51519.59935.11762.33178.14914.81569.43037.90083.32590.492
70.45060.24634.07148.20638.34348.88881.90070.37655.06531.76382.54791.43659.88274.56288.827
87.28590.39641.39551.67340.39870.613

希望产出:

75.914
25.439
37.554
92.558
etc.

我已尝试:

fscanf(Fid, %6.3f ,[3 inf]);
fscanf(Fid, %5.3f ,[3 inf]);
fscanf(Fid, %5.3f ,[3 inf]);
fscanf(Fid,[ %2d  char( . )  %3d ], [6 inf]);
最佳回答

Assuming every element is 6 characters you could do the following since fscanf isn t working. Note: I saved your sample into "numData.txt"

EDIT:这好得多。

fid = fopen( numData.txt , r );
numArray = textscan(fid, %6.3f ,inf);

专 员

numArray =

   75.9140
   25.4390
   37.5540
   ... etc
问题回答

暂无回答




相关问题
Is There Any Way Without File.ReadAllText?

As I love to develop file I/O applications and my new development platform is Windows Mobile. Is there any way to read all the file, without using File.ReadAllText? Because Windows Mobile doesn t ...

File paths in Java (Linux)

I have created a Java application that loads some configurations from a file conf.properties which is placed in src/ folder. When I run this application on Windows, it works perfectly. However when I ...

How do I create a string using a loop variable in MATLAB?

I have a loop like this: for i=1:no %some calculations fid = fopen( c:\out.txt , wt ); %write something to the file fclose(fid); end I want data to be written to different files like ...

热门标签