matching the count of indices of two arrays

5 Ansichten (letzte 30 Tage)
Daniel
Daniel am 31 Aug. 2011
Hi, Im trying to do match the number of index of A and B.
for example.. if A is (1x100 double) and B is (1x50 double),
I would manually write A=A(1:50) to truncate the A's index to match B's.
However, is there a way where a MATLAB code will automatically count the A's and B's index and match them?
i.e. n=countIndex(B);A=A(1:n);
does that make sense...??
Very Respectfully, Dan

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 31 Aug. 2011
Hi Daniel! This is what you want?
n = min(numel(A),numel(B));
idxequal = find(A(1:n)==B(1:n));
  1 Kommentar
Daniel
Daniel am 31 Aug. 2011
thank you soooooooooooo much
this worked. not entirely though, but 90% of the code did.
for some reason, command idxequal wasnt working.
so, i wrote: A=A(1:n);B=B(1:n) instead after the first line.
Thanks again!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by