Vectorise or make this code run faster

2 次查看(过去 30 天)
How would I make this code run faster:
for i=1:nRows
for j=1:nCols
Z=I(i,j,1)-I(i,j,2)-I(i,j,3);
end
end
Thank you

回答(1 个)

Guillaume
Guillaume 2018-11-17
This is really basic matlab
Z = I(:, :, 1) - I(:, :, 2) - I(:, :, 3);

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by