The error is telling you that this part of the statement is wrong:
segm(p).regs(:,:,rix)*rix
The error is saying that the element-wise multiplication doesn't have valid data types. Make sure
segm(p).regs(:,:,rix)
AND
rix
are valid types (integers or doubles).