使用xlswrite时出错

时间:2014-02-28 03:47:03

标签: matlab xls

所以我有这段代码。

转发=

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文件

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

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