Did you read what the error message said?
Unrecognized function or variable 'X'.
Error in untitled (line 3)
Z1 = zeros(1, length(X));
So what is X? Is it X1?
Z1 = zeros(1, length(X1));
Z2 = ones(1, length(X1));
I imagine the only reason this once worked was because there was a volatile copy of X just floating around in the workspace -- probably left over from when you changed variable names or something.