I am trying to change the order of a vector [ 1 2 3 4 5 6] into [ 3 4 5 1 2 6] while using a determinative vector B=[ 3 4 5],
but when I run the code I get a vector [3 4 5 2 1 6];
x == num
for i = 1:length(B)
if isequal(B(i),num(i)) == 0
tmp = num(i);
num(i) = num(B(i));
num(B(i)) = tmp;
end
end
2 Comments
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/538587-change-order-of-a-row-vector#comment_875479
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/538587-change-order-of-a-row-vector#comment_875479
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/538587-change-order-of-a-row-vector#comment_875503
Direct link to this comment
https://es.mathworks.com/matlabcentral/answers/538587-change-order-of-a-row-vector#comment_875503
Sign in to comment.