Cliff
2006-01-30 14:16:17 UTC
Hi,
I have a function that accepts an input n from a user.I want to force
the user to supply a number that is always a power of 2,i.e one of
2,4,8,16,....
This is what i have as a requirement for the number;
n = power(2,x)
therefore
x = log10(n)/log10(2)
All numbers{n} that give whole numbers i.e 1,2,3 etc when put into
the above equation satisfy my requirement.Now how do I ask Matlab to
check if a number is a whole number?
I thought isinteger(x) would work but later realise it want meant for
such use.
I want to make sure if say x=1.234 i reject the given n unless if n
gives x={whole number}
Thanks
I have a function that accepts an input n from a user.I want to force
the user to supply a number that is always a power of 2,i.e one of
2,4,8,16,....
This is what i have as a requirement for the number;
n = power(2,x)
therefore
x = log10(n)/log10(2)
All numbers{n} that give whole numbers i.e 1,2,3 etc when put into
the above equation satisfy my requirement.Now how do I ask Matlab to
check if a number is a whole number?
I thought isinteger(x) would work but later realise it want meant for
such use.
I want to make sure if say x=1.234 i reject the given n unless if n
gives x={whole number}
Thanks