You are getting a problem because you are trying to multiply matrices of different sizes.
This is partly because you have set xx
to the single value 1. If you change this to a matrix of the same size as x you this should work with with the ones, e.g.
xx=ones(size(x))
Also, in your T1 and T2 functions, your dy matrix is 2 rows by 1000 columns. You must multiply by a matrix of the same dimensions - you could do this for example:
y=F(xx) + dy.*[x-xx;x-xx];
in T1 and:
y=T1(xx,x)+ (ddy.*[x-xx;x-xx].*[x-xx;x-xx])/2;
in T2
There is also a slight typo on one line in T2 (an x should be an xx):
ddy=[-cos(xx); -4*sin(2*xx)]; % 2nd derivative at xx
Finally, I found the use of xx
as a variable slightly confusing. I would have chosen a
as used here:
[http://en.wikipedia.org/wiki/Taylor_series]