【问题标题】:Error using xlswrite使用 xlswrite 出错
【发布时间】:2014-02-28 13:09:10
【问题描述】:

所以我有这段代码。

前进 =

ForwardDifferentiation(a, eq, deltaX);
    Backward = BackwardDifferentiation(a, eq, deltaX); 
    Central = CentralDifferentiation(a, eq, deltaX); 
    SecDeriv = second(a, eq, deltaX); 
    ThirdDeriv = third(a, eq, deltaX);
    FourthDeriv = fourth(a, eq, deltaX); 

    fprintf('y'' using Forward Difference @x=%g is: %.5f', a, Forward);
    fprintf('\ny'' using Backward Difference @x=%g is: %.5f', a, Backward);
    fprintf('\ny'' using Central Difference @x=%g is: %.5f', a, Central);
    fprintf('\ny" using Second Derivative @x=%g is: %.5f', a, SecDeriv);
    fprintf('\ny"'' using Third Derivative @x=%g is: %.5f', a, ThirdDeriv);
    fprintf('\ny"" using Fourth Derivative @x=%g is: %.5f', a, FourthDeriv);

    filename = 'NumericalDifferentiation.xlsx';
    A = {'y''(Forward Diff)', 'y''(Backward Diff)', 'y''(Central Diff)', ...
    'y"', 'y"''', 'y""'; Forward, Backward, Central, SecDeriv, ...
    ThirdDeriv, FourthDeriv};
    xlswrite(filename,A) % Writing an xls file

但是xlswrite总是会出错:

使用 xlswrite 时出错(第 220 行) 文件 C:\Program Files\MATLAB\R2013a\bin\MP2a\NumericalDifferentiation.xlsx 不是 可写。它可能被另一个进程锁定。

和

NumDif 中的错误(第 66 行) xlswrite(filename,A) % 写入 xls 文件

我该如何解决这个问题?

【问题讨论】:

    标签: matlab xls


    【解决方案1】:

    如果.xls 文件在某处打开,则不允许写入该文件。关闭所有程序中的.xls 文件,然后尝试运行代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-26
      相关资源
      最近更新 更多