I have a matrix 'Mat' and a vector 'v', I want to match the vector 'v' with the first row of 'Mat' such that I get an output 'res'. I tried using the ismember function and a code mentioned below
Mat=[1 356 4 457 7 91 6 4319 3310 322 ]v =[NaN 1 7 NaN 1 9 6 NaN 6 6] res= [NaN NaN 1 356 7 91 NaN NaN 1 356 9 33 6 431 NaN NaN 6 431 6 431]%%%%%%code I tried but did not work, it does not give numbers for repetative occurences of elemet in vector B
idx=setdiff(v,Mat(:,1)).';ans=zeros(numel(idx),1);idx=[idx' ans];res=sortrows([Mat;idx]);
Best Answer