MATLAB: Xls export problem

excel

>> xls_1
xls_1 =
857_386.xls
>> xlswrite(xls_1,a) ??? Error using ==> xlswrite at 213 Invoke Error, Dispatch Exception: Source: Microsoft Office Excel Description: ???????????????????:
??????????????? ??????????? ??????????????: < > ? [ ] : ? *? ????????????? 218 ????? Help File: C:\Program Files\Microsoft Office\OFFICE11\1028\xlmain11.chm Help Context ID: 0

Best Answer

OK, your problem is the special characters in the string. You can't have slashes and line breaks in a filename.
When you do xlswrite('xls_1',a); the filename is the literal string 'xls_1', which is why it writes to xls_1.xls. You need the filename stored in the char variable xls_1, so:
xlswrite(xls_1,a);
However, to do that, xls_1 has to be a valid filename string. This works:
xls_1 = sprintf('%i_%i.xls',x,y)
If you're ok with underscores in places of slashes in the dates, this also works:
xls_1 = sprintf('%i_%i_%s_%s.xls',...
x,y,regexprep(start_day,'/','_'),regexprep(end_day,'/','_'));