swiching elements of same vector
이전 댓글 표시
hi everybody, i have vector
X=[ 20; 0; 0;0; 100; 0;0;0;50];
i would like to have
X=[0;0;0;0;20;0;0;0;100];
so that each number take the next number case
채택된 답변
추가 답변 (1개)
Jos (10584)
2016년 4월 6일
편집: Jos (10584)
2016년 4월 6일
Easy:
X = [20 0 0 0 100 0 0 50 0]'
[i,~,v] = find(X)
X(i) = [0 ; v(1:end-1)]
댓글 수: 1
jean claude
2016년 4월 6일
편집: jean claude
2016년 4월 6일
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!