Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit:

How to reduce the matrix

Asked by Minnu on 2 May 2013


I have a matrix of size 830x27,want to reduce the size to some ax27 using processpca?how to reduce it?


Minnu on 2 May 2013

Now my matrix size is 10x27 .i want to know how to reduce the dimension of matrix without any loss of features

Zhang lu on 2 May 2013
for i = 1:floor(size(a,1)/n)
           eval(['a' num2str(i) ' = a(n*(i-1)+1:n*i,:)'])
if mod(size(a,1),n)~=0
    eval(['a' num2str(I) ' = a(n*i+1:end,:)'])
Jan Simon on 2 May 2013

No, Zhang, do not do this. Using EVAL to hide an index in the name of a varibale is a really bad idea. This reduces the processing speed substantially, impedes debugging and required equivalently obtuse methods to access the variables later. It would be tremendously smarter to use an index as index (!):

a{I} = a(n*i+1:end, :)

See Answers: FAQ how can I create A1, A2, ... in a loop



No products are associated with this question.

0 Answers

Contact us