Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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
Loops 输出多个数据集的函数_Loops_Dataset - Fatal编程技术网

Loops 输出多个数据集的函数

Loops 输出多个数据集的函数,loops,dataset,Loops,Dataset,我在MATLAB工作。 我有一个函数,它循环遍历目录中的所有文件,运行它们,并将它们的数据集输出连接到单个数据集中 有没有一种方法可以改变我的函数,让它输出所有单独的数据集以及统一的数据集 下面,名为“FileInfo”的数组有3列。第一列有文件名,第二列和第三列是输入 function [AllFunOutputs] = RunAllFuns(FileInfo) fileDir = dir('C:\MATLAB\Funs'); % get all file names in

我在MATLAB工作。 我有一个函数,它循环遍历目录中的所有文件,运行它们,并将它们的数据集输出连接到单个数据集中

有没有一种方法可以改变我的函数,让它输出所有单独的数据集以及统一的数据集

下面,名为“FileInfo”的数组有3列。第一列有文件名,第二列和第三列是输入

 function [AllFunOutputs] = RunAllFuns(FileInfo)     
 fileDir  = dir('C:\MATLAB\Funs');   % get all file names in directory 'Funs'
 files = {fileDir.name};                             
 funNames = strrep(files, '.m', '');  % strip the '.m' suffix from all files 
 funNames(:,1:2) = [];    
 funNames = transpose(funNames);

k = 1;               % below, match the function name with its argument
  for i=1:length(FileInfo)
    if strcmp(FileInfo(i,1),funNames(k,1))
      funNames(k,3) = FileInfo(i,2);
      k = k+1; 
     end
 end

                % create function handles

 fh_array = cellfun(@str2func,{funNames{:,1}},'UniformOutput', false);  

    X = [];     % below, concatenate all output datasets into a single dataset 

   for i=1:size((funNames),1) 
    X=[fh_array{i}(funNames(i,2),(funNames(i,3)))];
    X = X+1;
   end
所以。。。。。为什么这不能为我提供所有函数的输出数据集

nFcns = numel(fh_array);    % number of functions to evaluate 

    for i=1:size(nFcns)  
    [allresults] = feval(@(i)funNames(i,2),funNames(i,3));   
    end
非常感谢你的帮助和时间