使用系统(sprintf())从Matlab到R的转换

使用系统(sprintf())从Matlab到R的转换,r,matlab,R,Matlab,我试图将以下matlab代码翻译成R: clear all nsta = [1,2,3]; npx = [2,3,4,5]; npu = [2,3,4,5]; nmax = 2500; nome = 'MODEL1b'; system(sprintf('del %s.log',nome)); nfiles = 0; for k = 1:length(nsta) for i = 1:length(npx) for j = 1:length(npu)

我试图将以下matlab代码翻译成R:

clear all
nsta = [1,2,3];
npx  = [2,3,4,5];
npu  = [2,3,4,5];
nmax = 2500;
nome = 'MODEL1b';
system(sprintf('del %s.log',nome));
nfiles = 0;
for k = 1:length(nsta)
    for i = 1:length(npx)
        for j = 1:length(npu)
            nx = nsta(k);
            npar = (npx(i)^nx)*npu(j);
            if (npar < nmax)
                nfiles = nfiles+1;
                system(sprintf('copy %s%d%d%d.txt  %s.txt',nome,nx,npx(i),npu(j),nome));
                system(sprintf('copy input%d%d%d.txt  input.txt',nx,npx(i),npu(j)));
                system(sprintf('copy template%d%d%d.txt template.txt',nx,npx(i),npu(j)));
                tic;
                system(sprintf('RFuzzy %s',nome));
                time = toc;
                fprintf('Arquivo: %d    Config: %d%d%d    Time: %f',nfiles,nx,npx(i),npu(j),toc);
                system(sprintf('copy min.txt min%d%d%d.txt',nx,npx(i),npu(j)));
            end
        end
    end
end

显然,它没有运行第七行中的代码。正确翻译它有什么帮助吗?

取消链接(paste0(nome,.log'))
状态127表示找不到该命令:在这种情况下,
del
命令是分隔符。那么答案应该是什么呢?
del
应该由系统找到,即它应该在路径中。您还可以提供到
del
的直接路径。
rm(list = ls())
nsta <- c(1,2,3)
npx <- c(2,3,4,5)
npu <- c(2,3,4,5)
nmax <- 2500
nome <- "MODEL1b"
system(sprintf('del %s.log', nome))
nfiles <- 0
for(k in 1:length(nsta)){
  for(i in 2:length(npx)){
    for(j in 2:length(npu)){
      nx <- nsta[k]
      npar <- (npx[i]^nx)*npu[j]
      if(npar < nmax){
        nfiles <- nfiles + 1
        system(sprintf('copy %s%d%d%d.txt  %s.txt',nome,nx,npx[i],npu[j],nome))
        system(sprintf('copy input%d%d%d.txt  input.txt',nx,npx[i],npu[j]))
        system(sprintf('copy template%d%d%d.txt template.txt',nx,npx[i],npu[j]))
        system(sprintf('RFuzzy %s',nome))
        fprintf('Arquivo: %d    Config: %d%d%d    Time: %f',nfiles,nx,npx[i],npu[j])
        system(sprintf('copy min.txt min%d%d%d.txt',nx,npx[i],npu[j]))
      }
    }
  }
}
Warning message:
running command 'del MODEL1b.log' had status 127