can you attach a screenshot of the variable types?
it looks like you are trying to add a variable of type double to a variable of type unit8 or something along those lines. also, try to not designate the memory for b1 as type unit8 first. Rather, create b1 in the nested for-loop THEN change the variable type after the foor loop executes.
Also, this may help: https://www.mathworks.com/help/matlab/ref/typecast.html