I want to swap half of the elements of an array A with corresponding half of elements of another array B.Is there any built-in function for this operation or is there any shortcut ???Can anyone help me ????
k=1;
for i=1:nwpc
for j=i+1:nwpc
if(i<j) nwP3(k,1:cross_pt)=nwP1(i,1:cross_pt)
nwP3(k,cross_pt+1:pc)=nwP1(j,cross_pt+1:pc);
k=k+1;
nwP3(k,1:cross_pt)=nwP1(j,1:cross_pt);
nwP3(k,cross_pt+1:pc)=nwP1(i,cross_pt+1:pc);
k=k+1;
end
end
end
Example: input
A={1 2 3 4 5 6};
B={7,8,9,10,11,12};
output
C=={1,2,3,10,11,12}
D=={7,8,9,4,5,6}