function[k]= sampling_sinep(samp_step,n_a,n_b,n_c)
dim=(2/samp_step)+1;
s_v=zeros(dim,1);
m=1;
for k=-1:samp_step:1
s_v(m,1)=sin((2*pi*k));
m=m+1;
end
hist(s_v);
k=kurtosis(s_v);
When passed as a paramater samp_step=.00001 or less ,the function works correctly,but I've this warning: Warning: Size vector should be a row vector with integer elements. (at 13: s_v=zeros(dim,1))
Somebody have any idea?
Thanks
Alessio
As the message says, you need the size element of zeros to be an integer (i.e. dim). There's no guarantee that it will be from your code, although it could be that the values you intend to use for samp_step will always be okay.
You could either add a function in the defintion of dim which will convert to an integer (like floor), or you could add a check that 2/samp_step is an integer where you define dim with some default behaviour or error if it doesn't.
e.g.
dim = floor(2/samp_step + 1);
or
dim = 2/samp_step + 1;
if mod(dim,1) ~= 0
then
error('myFun:sampStep', 'The inverse of the sampling step argument must be a mutliple of 2')
end
I've not got a working matlab handy to test this, so I can't guarantee that the error catching will be enough to suppress the warning (or that it will work exactly as written) but I prefer it since it doesn't allow for mistaken inputs to generate surprising outputs.
Hazel
P.S.
"When passed as a paramater samp_step=.00001 or less ,the function works correctly"
Really? What about 0.0000097 ....
Thanks Hazel,
everything you said I was of help!
I have never considered the possibility of assigning not multiple values of two.
I understand my error!
Thanks
Alessio
> dim=(2/samp_step)+1;
> s_v=zeros(dim,1);
> When passed as a paramater samp_step=.00001 or less ,the function works
> correctly,but I've this warning: Warning: Size vector should be a row
> vector with integer elements. (at 13: s_v=zeros(dim,1))
There is no exact binary floating point representation for 1/10^N for
N>0 . 2 divided by the floating point representation of 1/10^N is not
necessarily going to be an exact integer.