MATLAB: Why is this code not running

for

yc=zeros(1,10);
xb=(pi./4);
for i=1:10
yc(i)=yc(i)+(((-1).^(i-1)).*((xb.^((2.*i)-1))./(factorial((2.*i)-1))));
end
plot(xb,yc,'--bx')
hold on
yd=sin(pi./4);
plot(xb,yd,'-k')
hold off

Best Answer

Undoubtedly, your computation of yc is incorrect, but here's how to get the plot working:
N=numel(yc);
plot(1:N,yc,'--bx', 1:N, ones(1,N)*yd, '*-.r')