This line defined Icrop as a double:
Icrop=zeros(1,1000000)
And the curly braces { } in this line use lcrop as a cell array:
Icrop{i} = etc.
That is causing the error. You can't index into Icrop as a cell array when it has been defined as a double.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!