Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex MATLAB-将包含在特定句子之间的文本从一个文件复制到另一个文件_Regex_Matlab_Copy Paste - Fatal编程技术网

Regex MATLAB-将包含在特定句子之间的文本从一个文件复制到另一个文件

Regex MATLAB-将包含在特定句子之间的文本从一个文件复制到另一个文件,regex,matlab,copy-paste,Regex,Matlab,Copy Paste,我在执行分类后得到了一些分数,这些分数保存在ASCII文件中,如下所示: Time taken to build model: 0.39 seconds === Predictions on test data === inst#, actual, predicted, error, probability distribution 1 4:Walking_ 4:Walking_ 0 0.015 0.061 *0.167 0.136 0.1

我在执行分类后得到了一些分数,这些分数保存在ASCII文件中,如下所示:

Time taken to build model: 0.39 seconds

=== Predictions on test data ===

inst#,    actual, predicted, error, probability distribution

     1 4:Walking_ 4:Walking_          0      0.015  0.061 *0.167  0.136  0.152  0.121  0.106  0.045  0.061  0.045  0.091
     2 4:Walking_ 4:Walking_          0      0.015  0.061 *0.167  0.136  0.152  0.121  0.106  0.045  0.061  0.045  0.091
     3 4:Walking_ 4:Walking_          0      0.015  0.045 *0.167  0.121  0.152  0.136  0.106  0.061  0.061  0.045  0.091
     4 4:Walking_ 4:Walking_          0      0.045  0.061 *0.167  0.121  0.152  0.136  0.106  0.015  0.03   0.076  0.091
     5 4:Walking_ 4:Walking_          0      0.03   0.061 *0.167  0.136  0.152  0.121  0.106  0.03   0.061  0.045  0.091
     6 10:jumping  9:running      +   0      0.03   0.045  0.106  0.121  0.136  0.091  0.076 *0.167  0.152  0.03   0.045

=== Stratified cross-validation ===
=== Summary ===

我想要的是通读文件并复制inst,actual,。。。和===分层交叉验证===到另一个文件。由于文件大小不同,使用正则表达式的解决方案最合适。提前谢谢。

我认为最好的方法是使用fscanf和fprintf。具体如下:

clear all 

fid = fopen('prova');

data = fscanf(fid,'%*[^=]%*[^\n]%[^=]',1);

fclose(fid);

fid = fopen('new','w');

fprintf(fid,'%c',data);

fclose(fid);
当然,只有在数据字段中不使用=时,此选项才有效。

请尝试