Depends exactly what you mean by "got an idea ... from a sci-fi book". If you mean "copied directly from a sci-fi book", you shouldn't be able to patent it -- the USPTO has accepted science fiction as prior art in the past. (Naturally, it's only prior art if it describes the method -- Star Trek transporters aren't prior art for anything, because the mechanisms behind how they work were never specified.)
The most famous example of fiction being cited as prior art is probably the method of raising a sunken ship by filling it with ping pong balls, where a 1949 Donald Duck cartoon was cited.
The most famous example of fiction being cited as prior art is probably the method of raising a sunken ship by filling it with ping pong balls, where a 1949 Donald Duck cartoon was cited.