开发者

Compare two vectors in Matlab

开发者 https://www.devze.com 2023-02-24 02:07 出处:网络
I think, the question might have already been asked before. But I could not find proper answer in this forum.

I think, the question might have already been asked before. But I could not find proper answer in this forum.

Acutally, I have 2 vectors( of unequal length). I need to compare the 2 vectors. I can do it using a for loop. But it is taking a very long time.

Any obvious method which I may be missising ?

here is a small code snippet:

a=[ 1 2 3 4 5 6 7 8 1 2 3 4];
b=[ 2 3 4];

How can we compare a and b. Basically I need the index in vector a when comparison returns true.

开发者_C百科

Thanks


You can use strfind() for this (it works with doubles):

idx = strfind(a, b);

idx will contain the indices of all matches.

0

精彩评论

暂无评论...
验证码 换一张
取 消