L is a cell.
L=
2,4,6 % j=1
1,6,8 % j=2
4,6 % j=3
r - 1x8 vector:
23 1 24 5 4 3 7 8
I want to highlight this code in my file:
UC=zeros(1,J);
for j=1:J
if ~isempty(L{j})
UC(j)=sum(r(L{j}));
end
end
I tried this:
UC = arrayfun(@(x)r(x), L, 1, 'UniformOutput', false);
but it seems that the cells are not suitable for this function.
Error using subsindex
Function 'subsindex' is not defined for values of class 'cell'.
source
share