Could you please tell how to store the "first_element" values in a matrix?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%code
first_element = [];end_element = [];A = [ 1 1 1 1 2 3 4 4 4 ; 1 2 3 4 5 5 5 5 5]; for this_row = A.'V = this_row'; X = diff(V)~=0;B = find([true,X]);E = find([X,true]);D = 1+E-B ;first_element = D(1,1)end_element = D(end);end%%%%%%%%%%%%%%%%%%%%
output of the following code is :
first_element = 4first_element = 1
But I want output to be :
first_element = [ 4 ; 1]%%%%%%%%%%%%%%%%%%%%%%%%%
Thanks
Best Answer