Hello Andrew,
Red = zeros(size(B));
Green = zeros(size(B));
Blue = zeros(size(B));
Red(B<=120) = 255;
Blue(B>150) = 255;
Green(B>120&B<=150) = 255;
RGB=cat(3,Red,Green,Blue);
Same basic approach, but some lines are dropped since you don't have to set something to zero if it's zero already. Shorter size commands are used. You could shorten it further by defining the RGB array at the start and dropping numbers into it, but then I think the code would lose clarity for no good purpose.
Best Answer