From: Fraser Dickson on 11 Mar 2010 03:17 Hi im trying to use the ismember() func to find out how many values in one matrix are present in the other matrix and that works find x = sum(ismember(matrixa,matrixb)); but what i also want to know is how do i extract the value in the matrix that is equal i.e a = [1;3;5;7;9] b = [1;5;8;10] how can i get x = 5 ( as it is present in both matrixes) Thanks
From: Jos (10584) on 11 Mar 2010 03:25 "Fraser Dickson" <fraser.dickson(a)gmail.com> wrote in message <hna8tu$1ru$1(a)fred.mathworks.com>... > Hi im trying to use the ismember() func to find out how many values in one matrix are present in the other matrix and that works find > > x = sum(ismember(matrixa,matrixb)); > > but what i also want to know is how do i extract the value in the matrix that is equal > > i.e > > a = [1;3;5;7;9] > b = [1;5;8;10] > > how can i get x = 5 ( as it is present in both matrixes) > > Thanks help intersect Jos
From: Bruno Luong on 11 Mar 2010 03:30 "Fraser Dickson" <fraser.dickson(a)gmail.com> wrote in message <hna8tu$1ru$1(a)fred.mathworks.com>... > Hi im trying to use the ismember() func to find out how many values in one matrix are present in the other matrix and that works find > > x = sum(ismember(matrixa,matrixb)); > > but what i also want to know is how do i extract the value in the matrix that is equal > > i.e > > a = [1;3;5;7;9] > b = [1;5;8;10] > > how can i get x = 5 ( as it is present in both matrixes) > INTERSECT can output the indexes for both arrays. Bruno
From: Jan Simon on 11 Mar 2010 05:00 Dear Fraser! > Hi im trying to use the ismember() func to find out how many values in one matrix are present in the other matrix and that works find > > x = sum(ismember(matrixa,matrixb)); > > but what i also want to know is how do i extract the value in the matrix that is equal If you've called ISMEMBER, you can use its answer! isCommon = ismember(matrixa,matrixb); numberOfCommon = sum(isCommon) valueCommon = matrixa(isCommon) Good luck, Jan
|
Pages: 1 Prev: running an .m file Next: Matlab Mex Compiler and Csdp.Exe Error |