gdp_p_h and p are vectors. But for some reason this doesn't want to work. I keep getting an error saying: "A(I) = X: X must have the same size as I"
for entry = gdp_p_h
function_array(end + 1) = polyval(p,entry)
end;
When using polyval, if entry is an array it will return something the same size.
In your case you are using the loop pretty badly, so entry will be a whole array and function_array(end+1) is only a single number, so it can not store an array.
2 options:
If you want to keep the loop (if you have more things inside), write it properly!
I am guessing that you want:
for ii=1:length(gdp_p_h)
entry=gdp_p_h(ii);
function_array(end + 1) = polyval(p,entry);
end
Else, if that's the only thing you are doing inside the loop, you just dont need it.
function_array=polyval(p,gdp_p_h);
will do the job.
Learn how to write for loops here: http://uk.mathworks.com/help/matlab/ref/for.html
function_array(end+1,:)?