matrix inversion and summation

I generate a hypothetical dataset using the following equation

$$z=x+iy=\omega(\zeta)=\frac{1}{ \zeta}+\sum_{k=1}^N \alpha_k \zeta^k$$

In matrix form, the equation can then be written as $z = A\alpha$, or,

$$\begin{bmatrix} z_1 \\ z_2 \\ \vdots \\ z_m \end{bmatrix} = \begin{bmatrix} \frac{1}{\zeta_1} & \zeta_1 & \zeta_1^2 & \cdots & \zeta_1^N \\ \frac{1}{\zeta_2} & \zeta_2 & \zeta_2^2 & \cdots & \zeta_2^N \\ \vdots & \vdots & \vdots & \ddots & \vdots\\ \frac{1}{\zeta_m} & \zeta_m & \zeta_m^2 & \cdots & \zeta_m^N \end{bmatrix} \begin{bmatrix} 1 \\ \alpha_1 \\ \alpha_2 \\ \vdots \\ \alpha_m \end{bmatrix}$$

For the current case, we will assume that $N=3$ and $\alpha_k=[0,-0.2,-0.01]$. And, $\zeta^k = e^{ik\theta}$ where $\theta = 0,\dots,2\pi$. Then, I used the following code to calculate $z$,

dumZ = 0;
sumdumZ = 0;
theta = linspace(0,2*pi,37);
xi = exp(1i.*theta);
for ii=1:length(theta)
for jj=1:lma
dumZ = ma(jj).*xi(ii).^jj;
sumdumZ = sumdumZ + dumZ;
end
zcon(ii) = 1./xi(ii)+sumdumZ;
dumZ = 0;
sumdumZ = 0;
end


which will give me a profile as shown in the following figure,

• Now, using the hypothetical data above, i.e. the zcon, I want to back-calculate the variable $\alpha_k$.

• To do this, I first created a matrix $A$. I have expanded the terms of matrix $A$ up to $370$ terms. The following code is used to generate the matrix $A$,

lx = length(zcon); N = 10*37; A = zeros(lx,N); for ii=1:lx for jj=1:N A(ii,jj) = xi(ii).^jj; end end A=[1./xi' A];

Then $\alpha_k$ can be easily obtained using the following operation in Matlab,

maiter = A\zcon;


which gives me a $370 \times 1$ matrix. To validate this, I calculate the "predicted" $z$ using the following code:

 zdirect = A*maiter;


Which results an exactly the same curve as shown below,

QUESTION

Now, coming to my question. Instead of using a direct calculation as shown above, i.e. the code zdirect = A*maiter, I want to use summation to calculate z for each $\theta$. Somehow, I could not get it right and cannot find the mistake. Below is the code that I used to calculate $z$

dumZ = 0;
sumdumZ = 0;
for ii=1:length(theta)
for jj=2:length(maiter)
dumZ = maiter(jj).*xi(ii)^(jj-1);
sumdumZ = sumdumZ + dumZ;
end
ziter(ii) = maiter(1)./xi(ii)+sumdumZ;
dumZ = 0;
sumdumZ = 0;
end


Instead, this is what I got

Because, if I compare the real part of zcon and ziter the are the same, but the imaginary part are different.