"julie86a KRATZ" <juliekratz@gmx.net> wrote in message <gn2kcl$c3d$1@fred.mathworks.com>...
> Hello everybody!
>
> How do I check if a number is a perfect cube?
>
> I would be very glad to hear from you
>
> Thanks
>
> jk

What do you have in mind when you say "a perfect cube"? Do mean that the number is an integer and has a cube root which is also an integer? The logical expression

(sign(x)*round(abs(x)^(1/3)))^3==x

should be true if x is this kind of perfect cube. (Note: I have used the absolute value of x here to avoid complex roots.)

"julie86a KRATZ" <juliekratz@gmx.net> wrote in message <gn2kcl$c3d$1@fred.mathworks.com>...
> Hello everybody!
>
> How do I check if a number is a perfect cube?
>
> I would be very glad to hear from you
>
> Thanks
>
> jk

As Matt has shown, Husam, the test with a^(1/3) fails to work properly most of the time. The trouble is with the fraction 1/3 which cannot be expressed exactly. A 1/2 or 1/4 power seems to work all right as far as I have tried. Algorithms do exist that can find any n-th root exactly for a number that is the n-th power of an integer. I once found one in an ancient book on arithmetic that had belonged to my father.

In article <gn2kcl$c3d$1@fred.mathworks.com>, juliekratz@gmx.net says...
> Hello everybody!
>
> How do I check if a number is a perfect cube?
>
> I would be very glad to hear from you
>
> Thanks
>
> jk
>

"Husam Aldahiyat" <numandina@gmail.com> wrote in message
news:gn2vq9$c3b$1@fred.mathworks.com...
> "julie86a KRATZ" <juliekratz@gmx.net> wrote in message
> <gn2kcl$c3d$1@fred.mathworks.com>...
>> Hello everybody!
>>
>> How do I check if a number is a perfect cube?
>>
>> I would be very glad to hear from you
>>
>> Thanks
>>
>> jk
>
> if mod(a^(1/3),1)
> s='no';
> else
> s='yes';
> end