More efficient way than a loop for this particular example
이전 댓글 표시
I code but I am never trained for it, so every once in a while I get suspicious of the possibility to do something more efficiently. Bottleneck there is the ConvertColors in-house function I use, but I think there is a better way to do the j loop. Thanks in advance.

EDIT: for some reason the editor won't indent, so see screenshot for better readibility.
referenceAchromaticGrating=zeros(screenHeight_px,spatialFrequency_px,3);
for i=0:spatialFrequency_px-1
luminance = meanLuminance+4*sin(2*pi*(1/spatialFrequency_px)*i);
RGB_array = ConvertColors('MWLRGB',[0,0,luminance],colorInfo);
for j=1:3
referenceAchromaticGrating(:,i+1,j)=RGB_array(j);
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!