我正在尝试准备一个高清视频处理的查找表,我的代码很好,但它需要很长的计算时间,我在Matlab中是新手,我不知道是否有可能加速这个循环的处理。
while a<1024
while b<1024
while c<1024
while d<1024
while e<1024
Result=xx; %by formula
f1(result,e+1)=bitor(f1(result,e+1),16);
f1(result,d+1)=bitor(f1(result,d+1),32);
f1(result,c+1)=bitor(f1(result,c+1),64);
f1(result,b+1)=bitor(f1(result,b+1),128);
f1(result,a+1)=bitor(f1(result,a+1),256);
e=e+1;
end
e=0;
d=d+1;
end
d=0;
e=0;
c=c+1;
end
d=0;
e=0;
c=0;
b=b+1;
end
d=0;
e=0;
c=0;
b=0;
a=a+1;
end发布于 2014-10-19 04:06:46
您需要预先分配您的f1对象(f1 = zeros(size(Result,1),1024),或者如果它是一个函数,则预先分配它所引用的任何数据存储空间的总大小。
否则,遍历循环所需的时间将呈指数增长(因为它会在每个循环中复制已分配的数据)。
我建议你访问:Techniques for Improving Performance
https://stackoverflow.com/questions/26441353
复制相似问题