2012-11-22 61 views

回答

1

有趣的小問題。我相信這個作品:

A = [-1 1 -1 1 -1 1 0 0 0 0 -1 1 0 0 -1 1 -1 1 0 0]; %# Set up an example vector 
I1 = [1, 1, A(1:end-2) - A(3:end)]; %# Index all repetitions of sets of two using zeros 
I1(A == 0) = 1; %# Ensure our index doesn't remove any of the 0's from the original vector 
Soln = A(I1 ~= 0); %# Obtain solution using nonzero entries of the index 
+0

好戲法!讚賞回答! –

+0

@joeblack沒有probs。如果您對我的回答感到滿意,請隨時點擊旁邊的刻度線,以便問題標記爲已回答。如果沒有,讓我知道爲什麼,也許我可以改進它。乾杯。 –

相關問題