In fact the matlab offers us a function called p i c

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a function called p i c m rnop (http://www.mathworks.com/access/helpdesk/help/toolbox/stats/index.html?/access/helpdesk/help/toolbox/stats/princomp.html&http://www.google.cn/search?hl=zhCN&q=mathwork+princomp&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq=) which can perform PCA conveniently. From the matlab help file on p i c m , rnop you can find the details about this function. But here we will analyze the code of the function of p i c m ( in matlab to find something different when comparing with SVD rnop) method. The following is the code of princomp and explanations to some emphasized steps. fnto [c soe ltn,tqae =picm() ucin p, cr, aet sur] rnopx; % PICM PicplCmoetAayi (etrdadsae dt) RNOP rnia opnn nlss cnee n cld aa. % [C SOE LTN,TQAE =PICM()tksadt mti Xad P, CR, AET SUR] RNOPX ae aa arx n % rtrstepicplcmoet i P,tes-aldZsoe i S eun h rnia opnns n C h ocle -crs n C % OE,teegnauso tecvrac mti o Xi LTN, RS h ievle fh oaine arx f n AET % adHtligsTsurdsaitcfrec dt piti TQAE n oeln' -qae ttsi o ah aa on n SUR. % Rfrne J Ewr Jcsn AUe' Giet PicplCmoet eeec: . dad ako, srs ud o rnia opnns % Jh Wly&Sn,Ic 19 p.12. on ie os n. 91 p -5 % B Jns31-4 . oe -79 % Cprgt19-02TeMtWrs Ic oyih 9320 h ahok, n. % $eiin 29$ $ae 20/11 2:14 $ Rvso: . Dt: 020/7 13:5 [,]=sz() mn iex; % gttelnho terw adclmso mti x e h eg fh os n oun f arx . r=mnm1n; i(-,) % mxpsil rn o X a osbe ak f ag=ma() v enx; % tema o eeyclm o X h en f vr oun f cnex=( -agoe(,):) etr x v(nsm1,); % cnesXb sbrcigofclm mas etr y utatn f oun en [,aetp]=sdcnex/qtm1,) Ultn,c v(etr.sr(-)0; % "cnm sz"dcmoiin eooy ie eopsto soe=cnexp; cr etr*c % terpeetto o Xi tepicplcmoetsae h ersnain f nh rnia opnn pc i nrot<3 f agu rtr; eun ed n ltn =da(aet.2 aet igltn)^; i( fr ltn =[aet1r;zrsnr1] aet ltn(:) eo(-,); soe:r1ed =0 cr(,+:n) ; ed n i nrot<4 f agu rtr; eun ed n tp=sr(ig1/aet1r)*cr(,:); m qtda(.ltn(:))soe:1r' tqae=smtp*m); sur u(m.tp' From the above code, we should pay attention to the following aspects when comparing with SVD method: First, Rows of correspond to observations, columns to var...
View Full Document

Ask a homework question - tutors are online