开发者

Compare two vectors in Matlab

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜