Author Topic: Getting "Unknown Flag" error using intersect() function  (Read 662 times)

Offline hidavi

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
Getting "Unknown Flag" error using intersect() function
« on: January 28, 2010, 12:41:42 AM »
so I just want to check if there are any equivalent elements between two randomly generated matrixes.  I use the following code:

X=rand(100)
Y=rand(100)
C=intersect(X,Y,1:100)

and I get the following error:

??? Error using ==> intersect at
160
Unknown flag.

Any ideas on what I'm doing wrong?  When I use the intersect function on two straight 1-row vector that I purposefully put some equal elements into, it works just fine.  Like, if I was to do:

A=[1;2;6;3;5;8]
B=[4;6;9;7;4;5]
C=intersect(A,B)

I'd get C=[5,6] which makes sense.

I read in MATLAB that you can use the intersect function with matrices as long as you also specify which rows you wanna look at...

Anyways, I would really appreciate any help and thanks for looking!

Matlab and SimuLink Development Forum

Getting "Unknown Flag" error using intersect() function
« on: January 28, 2010, 12:41:42 AM »