필터 지우기
필터 지우기

Any ideas how i can reduce the time effort?

조회 수: 1 (최근 30일)
Dennis_Pana
Dennis_Pana 2016년 7월 19일
편집: Dennis_Pana 2016년 7월 20일
design=[0.6250 0.8750; 0.2500 0.7500; 0.3750 0.1250; 0.8750 0.3750; 0.1250 0.6250; 0 0; 0.5000 0.5000; 0.7500 0.2500; 0.6875 0.0625; 0.0625 0.8125; 0.1875 0.6875; 0.3125 0.3125; 0.4375 0.9375; 0.5625 0.5625; 0.9375 0.1875; 0.8125 0.4375;]
v=16;
A=2;
m=2
dm=2;
summ=0
for i=1:v
for j=1:v
if j==A,
continue
end
for k=1:m
if k==dm
ddii=((design(i,k)-design(j,k))^2);
summ=summ+ddii;
else
ddii=((design(A,k)-design(j,k))^2);
summ=summ+ddii;
end
end
ddcc(j,i,:)=[j i summ];
summ=0;
end
cc(i,:)=min(nonzeros(ddcc(:,i,3)));
end
Comments: v is an integer lets say 16. A is an integer ( any number from 1 to 16 or v). Design is a matrix, if v=16 we can say that is a 16 by 2 matrix (16 rows 2 columns), the matrix contains only positive numbers between 0 and 1 (for example 0, 0.025,0.975,0.523). Trying to vectorize the calculation in order to reduce time significantly.
Thank you in advance.
  댓글 수: 2
per isakson
per isakson 2016년 7월 19일
편집: per isakson 2016년 7월 19일
Modify the code so it's possible to run it and provide sample input data.
Dennis_Pana
Dennis_Pana 2016년 7월 19일
Try the code now. Thank you for your effort.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by