It was frustrating that Matlab did not has a robust nipals function so I wrote one for my project and share here.
It looks to be a bug on line 37 (pcvar = zeros(varCount,1);). Change to (pcvar = zeros(a,1);) to get the correct size of pcvar (number of elements in pcvar should be equal number of desired components).
That's weird. There is no recursion in this function. You can send your data and script to me: firstname.lastname@example.org
I will check that for you.
This is the message I got:
???Maximum recursion limit of 750 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> nipals
Is it possible you run it as a script while it is a function. X is the input matrix.
X = rand(5);
See if it gives you some result.
This is the error.
??? Input argument "X" is undefined.
Error in ==> nipals at 33
[obsCount,varCount] = size(X);
Hi could you give me the error message?
Line 33 is [obsCount,varCount] = size(X);
I cannot see there is any error here.
Sir, it shows that there is an error in the line 33. Can you please correct it? thank you for providing this program.
Line 48 (6/10/2013): prec = thnew-th; --> prec = (thnew-th)'*(thnew-th);