You're indexing like this:
for x = 1:20:2001
g(x) = blah;
end
You should be indexing like this:
for i = 1:1:100
x = x + dx;
g(i) = blah;
end
I'm not sure if you have another problem in the code - me no know what gpoly does!
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!