count = 1;
for n = 2: 97
for m = 2:length(time)
for i=3:numApRH
for j=2:numRawRH
for p = 2:numMapPT
PT_load(count, 1) = date=ap{m,1};
PT_load(count, 2) = t=ap{n,2};;
PT_load(count, 3) = raw{j,1};
PT_load(count, 4) = raw{j,3}*ap{m,i};
PT_load(count, 5) = map{p,32};
PT_load(count, 6) = map{p,33};
count = count + 1;
end
end
end
end
end
end
end
end

댓글 수: 1

Jan
Jan 2017년 7월 21일
편집: Jan 2017년 7월 21일
You forgot to ask a question.

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

 채택된 답변

Jan
Jan 2017년 7월 21일
편집: Jan 2017년 7월 21일

0 개 추천

If you want to increase the speed, care for pre-allocating PT_load.
Then avoid repeated work inside the loops:
count = 0;
PT_load = zeros(96 * (length(time) - 1) * (numApRH - 2) * ...
(numRawRH - 1) * (numMapPT - 1), 6);
q = zeros(1,6);
for n = 2: 97
q(2) = ap{n,2};
for m = 2:length(time)
q(1) = ap{m,1};
for i = 3:numApRH
ap_mi = ap{m,i};
for j = 2:numRawRH
q(3) = raw{j,1};
q(4) = raw{j,3} * ap_mi;
for p = 2:numMapPT
% ??? PT_load(count, 1) = date=ap{m,1}; ???
% Where does the "date =" come from? It is invalid syntax!
% ??? PT_load(count, 2) = t=ap{n,2};; ???
% Same for "t=" ???
q(5) = map{p,32};
q(6) = map{p,33};
count = count + 1;
PT_load(count, :) = q;
end
end
end
end
end
Ups: There are 3 "end" too much in the code. Please post working code only.
Now compare the speed and decide, if this is still the bottleneck of your code.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

pg
2017년 7월 21일

편집:

Jan
2017년 7월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by