Don't really need a function for that although could wrap in one if desired -- It would just be
M=x.^N;
NB: N in such an expression can be a vector such as [1:4] to return first four.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!