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!