Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
もしも
a=[5 8 1 2 6 7 1 4 2 3 7 8]; b=[7 6 3 1 5 4 2 0 1 8 9 4];
それから
a1=[1 7 3]
行列に対応し、dは[3 4 8]
[3 4 8]
da対応する値の正確な位置です。この値を見つけるにはどうすればよいですか?
d
a
これを試して:
c = [] for i = 1:length(a1) index = find(a == a1(i)); c = [c, index(1)] end d = [] for i = 1:length(c) d = [d, b(c(i))] end
出力は[348]です
お役に立てれば。
ワンライナーとして:
arrayfun(@(x) b(find(a == x, 1, 'first')), a1)