From: Scarlett on
Using the following few lines of code

function F=sensklb(Io,Ho,s,a,b)
clear t;
syms t;
clear K;
clear F;
F=zeros(size(s));
K=1;

I get the error

??? Error using ==> zeros
Trailing string input must be a valid numeric class name.

*Also note that the inputted s value is an integer value that is >0.

But, using the same commands in my workspace, I don't get an error and my matrix F is created! Any ideas as to what may be happening?

Thank you!
From: Walter Roberson on
Scarlett wrote:
> Using the following few lines of code
>
> function F=sensklb(Io,Ho,s,a,b)
> clear t;
> syms t;
> clear K;
> clear F;
> F=zeros(size(s));
> K=1;
>
> I get the error
>
> ??? Error using ==> zeros
> Trailing string input must be a valid numeric class name.

That is very odd unless you have defined your own routine named "size".

I suggeswt that just before the zeros() call, that you add some
temporary statements,

which size
disp(size(s))
From: Matt Fig on
In addition to what Walter said, is this a nested function? If not then there is no need to clear variables at the start of a function.
From: Scarlett on
Walter Roberson <roberson(a)hushmail.com> wrote in message <4_VJn.16983$TL5.4043(a)newsfe24.iad>...
> Scarlett wrote:
> > Using the following few lines of code
> >
> > function F=sensklb(Io,Ho,s,a,b)
> > clear t;
> > syms t;
> > clear K;
> > clear F;
> > F=zeros(size(s));
> > K=1;
> >
> > I get the error
> >
> > ??? Error using ==> zeros
> > Trailing string input must be a valid numeric class name.
>
> That is very odd unless you have defined your own routine named "size".
>
> I suggeswt that just before the zeros() call, that you add some
> temporary statements,
>
> which size
> disp(size(s))



I'm using the matlab function for size.

I added the disp(size(s)) function to the code, which returned 1 1. But the error for my zeros command still showed up.
From: Walter Roberson on
Scarlett wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <4_VJn.16983$TL5.4043(a)newsfe24.iad>...
>> Scarlett wrote:
>> > Using the following few lines of code
>> > > function F=sensklb(Io,Ho,s,a,b)
>> > clear t;
>> > syms t;
>> > clear K;
>> > clear F;
>> > F=zeros(size(s));
>> > K=1;
>> > > I get the error
>> > > ??? Error using ==> zeros
>> > Trailing string input must be a valid numeric class name.


> I'm using the matlab function for size.
>
> I added the disp(size(s)) function to the code, which returned 1 1. But
> the error for my zeros command still showed up.

Odd. Next I would double-check that you are using Matlab's zeros(), and
then I would start trying to debug the zeros function itself (I am not
sure if the source is available or not.)

In the meantime, you can use

SS = num2cell(size(s));
F = repmat(typecast(0, class(s)), SS{:});