MATLAB: Vector/matrix Initialization

vector matrix initialize

Matlab newbie here, so be gentle.
I am trying to port some Matlab code to C/C++ and am struggling to understand some of the syntax.
In particular, the following code segment eludes me:
if i0<i1
k=[i1 i i0];
elseif i0>i
k=[i0 i1 i];
elseif i1<i
k=[i i0 i1];
end
v=1:length(s);
v(k(1))=[];
v(k(2))=[];
v(k(3))=[];
for k=1:length(v)
px=s(v(k),1);
py=s(v(k),2);
end;
As I understand it, the first if-then block creates k as a one row, three column matrix. I am simply lost by the next code block. Any help in understanding what it means (especially in C/C++ form) appreciated.
Thanks

Best Answer

The first two blocks don't make much sense. Assuming that the one of those if conditions is true then vector k will get defined with the same three value (in different orders). The vector k is then used to remove some values from v, but the order is irrelevant. k is not used again (it gets reassigned in the third block of code). Therefore the first two blocks are simply equivalent to:
v = 1:length(s);
v([i1,i,i0]) = [];