Code covered by the BSD License  

Highlights from
Nipals algorithm for Principle Component Analysis

3.0

3.0 | 1 rating Rate this file 16 Downloads (last 30 days) File Size: 1.79 KB File ID: #42142
image thumbnail

Nipals algorithm for Principle Component Analysis

by

 

10 Jun 2013 (Updated )

This function is written largely based on nipals function from R chemometrics package.

| Watch this File

File Information
Description

It was frustrating that Matlab did not has a robust nipals function so I wrote one for my project and share here.

Required Products MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Other requirements Actually I created this by octave and it runs without any problem in MATLAB R2013a
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
17 Feb 2014 Eirik

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).

15 Jul 2013 Qiaonan Duan

That's weird. There is no recursion in this function. You can send your data and script to me: zfrlender@gmail.com
I will check that for you.

15 Jul 2013 Shivakumar

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

15 Jul 2013 Qiaonan Duan

Is it possible you run it as a script while it is a function. X is the input matrix.

Try:
X = rand(5);
nipals(X,2);

See if it gives you some result.

15 Jul 2013 Shivakumar

This is the error.
??? Input argument "X" is undefined.

Error in ==> nipals at 33
[obsCount,varCount] = size(X);

12 Jul 2013 Qiaonan Duan

Hi could you give me the error message?
Line 33 is [obsCount,varCount] = size(X);
I cannot see there is any error here.

12 Jul 2013 Shivakumar

Sir, it shows that there is an error in the line 33. Can you please correct it? thank you for providing this program.

Updates
11 Jun 2013

Line 48 (6/10/2013): prec = thnew-th; --> prec = (thnew-th)'*(thnew-th);

Contact us