This solution is outdated. To rescore this solution, sign in.
-
1 Comment
Haoyu Dai
on 29 May 2020
function y = common_by_row(x)
y=[];
[r,c]=size(x);
if r>0
a=x(1,:);
cnt=zeros(1,c);
for j=1:c
for i=1:r
if isempty(find(x(i,:)==x(1,j)))==0
cnt(j)=cnt(j)+1;
end
end
end
for j=1:c
if cnt(j)==r&&x(1,j)~=NaN&&ismember(x(1,j),y)==0
y=[y x(1,j)];
end
end
y=sort(y);
end
end
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!