Reputation: 3
So I have this piece of code.
Forward =
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
But errors always occur about the xlswrite:
Error using xlswrite (line 220) The file C:\Program Files\MATLAB\R2013a\bin\MP2a\NumericalDifferentiation.xlsx is not writable. It may be locked by another process.
and
Error in NumDif (line 66) xlswrite(filename,A) % Writing an xls file
How could I fix this?
Upvotes: 0
Views: 1887
Reputation: 235
If the .xls
file is open somewhere, it does not allow to write the file. Close the .xls
file from all the programs and then try to run the code.
Upvotes: 1