View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Nipals algorithm for Principle Component Analysis

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

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

Nipals algorithm for Principle Component Analysis



10 Jun 2013 (Updated )

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

| Watch this File

File Information

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

Eirik (view profile)

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

Comment only
15 Jul 2013 Qiaonan Duan

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

Comment only
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

Comment only
15 Jul 2013 Qiaonan Duan

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.

Comment only
15 Jul 2013 Shivakumar

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

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

Comment only
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.

Comment only
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.

11 Jun 2013 1.2

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

Contact us