From: Danielle Leblanc on 9 Jul 2010 03:42 I have vectors A B C D that have the same size. Is there any function that permits me to find the common numbers betweeb the 4. ismember works for only 2 vectors I believe.
From: Oleg Komarov on 9 Jul 2010 04:19 "Danielle Leblanc" <danielleblanc2004(a)hotmail.com> wrote in message <i16jsd$3p2$1(a)fred.mathworks.com>... > I have vectors A B C D that have the same size. Is there any function that permits me to find the common numbers betweeb the 4. ismember works for only 2 vectors I believe. You can use a recursive call to ismember: function Out = recursiveIsmember(varargin) Out = ismember(varargin{1},varargin{2}); Out = varargin{1}(Out); varargin(1:2) = []; if ~isempty(varargin) Out = recursiveIsmember(Out,varargin{:}); end end recursiveIsmember(1:100,2:10,5:80,3:120) ans = 5.00 6.00 7.00 8.00 9.00 10.00 Oleg
From: Oleg Komarov on 9 Jul 2010 04:51 "Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <i16m1s$k97$1(a)fred.mathworks.com>... > "Danielle Leblanc" <danielleblanc2004(a)hotmail.com> wrote in message <i16jsd$3p2$1(a)fred.mathworks.com>... > > I have vectors A B C D that have the same size. Is there any function that permits me to find the common numbers betweeb the 4. ismember works for only 2 vectors I believe. > > You can use a recursive call to ismember: > > function Out = recursiveIsmember(varargin) > > Out = ismember(varargin{1},varargin{2}); > Out = varargin{1}(Out); > varargin(1:2) = []; > > if ~isempty(varargin) > Out = recursiveIsmember(Out,varargin{:}); > end > end > > recursiveIsmember(1:100,2:10,5:80,3:120) > ans = > 5.00 6.00 7.00 8.00 9.00 10.00 > > Oleg The example fits your needs but I used inappropriately ismember (from a theoric point of view). I should have used intersect (which uses ismeber). Oleg
From: Oleg Komarov on 30 Jul 2010 11:44 "Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <i16ntp$d93$1(a)fred.mathworks.com>... > "Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <i16m1s$k97$1(a)fred.mathworks.com>... > > "Danielle Leblanc" <danielleblanc2004(a)hotmail.com> wrote in message <i16jsd$3p2$1(a)fred.mathworks.com>... > > > I have vectors A B C D that have the same size. Is there any function that permits me to find the common numbers betweeb the 4. ismember works for only 2 vectors I believe. > > > > You can use a recursive call to ismember: > > > > function Out = recursiveIsmember(varargin) > > > > Out = ismember(varargin{1},varargin{2}); > > Out = varargin{1}(Out); > > varargin(1:2) = []; > > > > if ~isempty(varargin) > > Out = recursiveIsmember(Out,varargin{:}); > > end > > end > > > > recursiveIsmember(1:100,2:10,5:80,3:120) > > ans = > > 5.00 6.00 7.00 8.00 9.00 10.00 > > > > Oleg > > The example fits your needs but I used inappropriately ismember (from a theoric point of view). > I should have used intersect (which uses ismeber). > > Oleg I created this submission to meet this kind of requirement: http://www.mathworks.com/matlabcentral/fileexchange/28341-set-functions-with-multiple-inputs z = intersectm(a,b,c,d,...); Oleg
|
Pages: 1 Prev: Simulink Video to GUI Next: right censoring example for real valued r.v. |