Rather than hard-coding the function you want to solve, you might want to create a function handle to the function and use that function handle to evaluate the function. That way you could specify a function from an example in your textbook (I'm assuming this is a homework assignment) and compare the results of your code with the textbook.
n = 3;
f = @(x) x.^n;
% This returns the cubes of the numbers 0 through 4
y = f(0:4)
f = @(x) 2*x+3;
% Now this is two times the numbers 0 through 4 plus 3.
% Same exact evaluation code, different function
y = f(0:4)