From: William on
I've been having a little difficulty with an xlswrite command, and was hoping someone could help. I have the following code:

xlssheetnames={'AllYrStatistics'; '7YrStatistics'; '5YrStatistics'; '3YrStatistics'; '2YrStatistics'; '1YrStatistics'};
for n = 1:6
xlswrite('Shortlist Outputs.xls', OutputMtx(:,:,n), xlssheetnames(n), 'F26:J60');
end

When I try to run this code, I get the following error message:
"??? Error using ==> xlswrite at 156
Sheet argument must be a string or a whole number greater than 0."

Could someone help me with why it doesn't recognise the sheet name I've passed in as a string, and how to fix it? Thanks.
From: ImageAnalyst on
Try xlssheetnames{n} (braces instead of parentheses) and see if that
works.
From: TideMan on
On Jun 10, 2:05 pm, "William " <billyte...(a)yahoo.com> wrote:
> I've been having a little difficulty with an xlswrite command, and was hoping someone could help. I have the following code:
>
> xlssheetnames={'AllYrStatistics'; '7YrStatistics'; '5YrStatistics'; '3YrStatistics'; '2YrStatistics'; '1YrStatistics'};
> for n = 1:6
>     xlswrite('Shortlist Outputs.xls', OutputMtx(:,:,n), xlssheetnames(n), 'F26:J60');
> end
>
> When I try to run this code, I get the following error message:
> "??? Error using ==> xlswrite at 156
> Sheet argument must be a string or a whole number greater than 0."
>
> Could someone help me with why it doesn't recognise the sheet name I've passed in as a string, and how to fix it? Thanks.

Use curly brackets, not parentheses:
xlssheetnames{n}
From: William on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <9f607b32-3772-413b-9ca3-c60a850804da(a)i28g2000yqa.googlegroups.com>...
> Try xlssheetnames{n} (braces instead of parentheses) and see if that
> works.

That did it, thanks very much for your help.