Top 5% contributor

**44**Contributions

n=3; x=meshgrid(1:n,1:n); y=x';

accepted

1

Answered 2 years ago

[~,Bsort]=sort(B); %Get the order of B C=A(Bsort) C = 1 9 4 5 8

accepted

1

Answered 2 years ago

This should do it: sum(matrix2(matrix1~=0))

accepted

0

Answered 2 years ago

Answering your second question A=bsxfun(@eq,x,y');

accepted

0

Answered 2 years ago

c=unique(a); b=[c, sum(bsxfun(@eq,a(:),c'))'] b = 3 3 4 2 5 2 6 3 7 ...

accepted

0

Answered 2 years ago

This should work: POS(POS(:,2)==0,2)=1;

accepted

0

Answered 2 years ago