Please im having this messeage displayed when using xlswrite function

31 views (last 30 days)
Warning: Added specified worksheet. > In xlswrite>activate_sheet at 284 In xlswrite>ExecuteWrite at 256 In xlswrite at 213 In mainanalysis at 17

Accepted Answer

Cedric
Cedric on 22 Aug 2015
Edited: Cedric on 22 Aug 2015
This is a warning that informs you that you are operating on a spreadsheet that doesn't exist, and hence adding it to the workbook. If you know that it is normal, you can disable this warning specifically as follows (put it before the call to XLSWRITE):
warning( 'off', 'MATLAB:xlswrite:AddSheet' ) ;
  2 Comments
Tijjani Aminu Kuda
Tijjani Aminu Kuda on 22 Aug 2015
Edited: Cedric on 22 Aug 2015
Thank you.
But actually I want to saving data using for loop, with the loop iteration specifying the sheet number. it works for sometme then start giving me error: could not save in xlsx file rather in .csv file. attached is the programme.
close all;
clear all;
fs = 44100;
Ts= 1/fs;
N = 11025;
load F81.mat
for k1 = 1:20
m =F84(k1,:);
imf = emd(m);
for k = 1:length(imf)
b(k) = sum(imf{k}.*imf{k});
end
E = sum(m.^2);
sal = b/E;
filename = 'test.80.xlsx';
sheet = k1;
xlRange1 = 'B5';
xlswrite(filename,sal,sheet,xlRange1);
c = zeros(1,30);
for k = 1:30
r = corrcoef(m(1:N-k),m(1+k:end));
c(k) = r(1,2);
end
filename = 'test.80.xlsx';
sheet = k1;
xlRange2 = 'B15';
xlswrite(filename,c,sheet,xlRange2);
z = zeros(1,30);
for k = 1:30
z(k) = mai(m,k);
end
filename = 'test.80.xlsx';
sheet = k1;
xlRange3 = 'B25';
xlswrite(filename,z,sheet,xlRange3);
end
Cedric
Cedric on 22 Aug 2015
Edited: Cedric on 22 Aug 2015
Is it still crashing if you replace all:
sheet = k1;
with
sheet = sprintf( 'Sheet%d', k1 ) ;
Note that, as Walter mentions below, it is very slow to access series of sheets using XLWRITE/XLSREAD.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 22 Aug 2015
xlswrite() starts up and stops Excel every time. It is not suitable for using in a longer loop. I think I recall that Image Analyst has written that xlswrite() does not always clean up resources sufficiently so after enough calls it will start to fail (it might not be the fault of xlswrite, it might be activex.) xlswrite1() is offered as a solution; see above

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!