% Let's construct a struct array.

p = struct();

% It does not matter if this assignment exists or not.
%p(1) = [];

% If you uncomment this assignment, the problem disappears.
%p(1) = struct('channel', 0);

for i = 2:100
	r = rand(1);
	if r < 0.33
		c = 'A';
	elseif r < 0.67
		c = 'B';
	else
		c = 'C';
	endif

	p(i) = struct('channel', c);
endfor

% Create a logical mask for all elements with channel = 'B'.
mask = [p.channel] == 'B';

% Print the channel of all chosen elements.
[p(mask).channel]

% You would expect it to print a string of B characters.
% Instead, it prints arbitrary entries.
