The MATLAB code below is to factorize a non-singular matrix into Z-matrix via WZ-factorization. However, I got the error message "Not enough input arguments".
function coder=WZfactorization(A)
A=input('matrix A =');
n=size(A);
for k =1:n/2-1
k2 = n-k-1;
det = A(k,k)*A(k2,k2)-A(k2,k)*A(k,k2);
for i=k+1:k2-1
w(i,k) = (A(k2,k)*A(i,k2)-A(k2,k2)*A(i,k))/det;
w(i,k2) = (A(k,k2)*A(i,k)-A(k,k)*A(i,k2))/det;
for j = k+1 : k2-1
A(i,j) = A(i,j)+w(i,k)*A(k,j)+w(i,k2)*A(k2,j);
end
end
end
A(i,j)=Z;
end
For instance the code should factorize
$A=\left(
\begin{array}{cccccc}
2 & 1 & 3 &-6 & 3 &3 \\
10 & 6 & 9 &-13 & 10 &14 \\
12 & 13 & 12 &-13 & 19 &17 \\
8 & 10 & 11 &-4 & 12 &11 \\
12 & 8 & 13 &-20 & 14 &17 \\
3 & 1 & 1 &-1 & 1 &4
\end{array}\right)$
$\qquad$ to $\qquad$
$Z =\left(
\begin{array}{cccc}
2 & 1 & 3 &-6 & 3 &3 \\
0 & 2 & 1 &1 & 2 &0 \\
0 & 0 & -4 &6 & 0 &0 \\
0& 0 & 2 &2 & 0 &0 \\
0 & 3 & 2 &0 & 3 &0 \\
3 & 1 & 1 &-1 & 1 &4
\end{array}\right)$
Another example is that the code should also factorize
$A=\left( \begin{array}{cccc} 5 & 4 & 1 & 1 \\ 4 & 5 & 1 & 1 \\ 1&1&4&2 \\ 1&1&2&4 \end{array}\right)$ $\qquad$ to $\qquad$ $Z =\left( \begin{array}{cccc} 5 & 4 & 1 & 1 \\ 0 & 1.7895 & 1.1053 & 0\\ 0&0.1053&2.9474&0 \\ 1&1&2&4 \end{array}\right)$
Thank you for your help.
Potential mistakes:
Note that in your Matlab code, $w$ and $Z$ are your input rather than your output.
I don't see $w$ are being used as an input
Also, coder, $wk1$, and $wk2$ are not defined in your code. Are they global variables or are those syntax error?
When you call your function as the way it is written now, it should be of the form of
$$coder=WZfactorization(w,Z)$$
what you want perhaps is
$$coder=WZfactorization()$$
or personally I prefer $$coder=WZfactorization(A)$$ rather than asking for user input.
Note taht coder is not assigned in your current code.