How to reduce the matrix

조회 수: 1 (최근 30일)
Minnu
Minnu 2013년 5월 2일
Sir,
I have a matrix of size 830x27,want to reduce the size to some ax27 using processpca?how to reduce it?
  댓글 수: 4
Zhang lu
Zhang lu 2013년 5월 2일
a=rand(830,27);
n=30;
for i = 1:floor(size(a,1)/n)
eval(['a' num2str(i) ' = a(n*(i-1)+1:n*i,:)'])
end
if mod(size(a,1),n)~=0
I=floor(size(a,1)/n)+1;
eval(['a' num2str(I) ' = a(n*i+1:end,:)'])
end
Jan
Jan 2013년 5월 2일
편집: Jan 2013년 5월 2일
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, :)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by