From: us on
"Kenneth Galea"
> x=pi; % <- bad data marker...
> v=[x x 2 3 4 x 1 1 2 8 x x x x 4 5 8 9];
> % i need to have outputs (2&4) (1&8) (4&9) i.e. the first and last element of each set.

one of the solutions

x=pi; % <- bad data marker...
v=[x x 2 3 4 x 1 1 2 8 x x x x 4 5 8 9];
ix=[false,v~=pi,false];
ib=strfind(ix,[0,1]);
ie=strfind(ix,[1,0])-1;
r=[v(ib);v(ie)]
%{
% r =
2 1 4
4 8 9
%}

us