- In MATLAB indexing starts from 1, therefore "V(:,0)" or "beta(0)" throws error. You can use "V(:,1)" and "beta(1)". Also, "j" should start from 2 (since your V(:,1) is the initial normalized vector).
- The expression "alpha(j-1) = V(:,j)' .* w" performs the element wise multiplication where as for the Lancoz process you need to perform scalar multiplication of the two vectors to get the projection of "w" onto "v(:,j)".
- To orthogonalize the vector "w" subtract the projection of "w" onto "V(:,j)" to remove the component of "w" that lies along "V". Therefore when you are updating "w" subtract the projection of "w" onto "V(:,j)" which is "w = w - V(:,j) * alpha(j)".