insert zero in chosen column of matrix randomly
조회 수: 1 (최근 30일)
이전 댓글 표시
I have
A=[
1 2 1 4
3 4 1 4
4 5 1 5
5 7 1 6
7 9 1 9];
I want to put zero for only one entery in column 3 randomly.
result shoud be
A=[
1 2 0 4
3 4 1 4
4 5 1 5
5 7 1 6
7 9 1 9];
or
A=[
1 2 1 4
3 4 1 4
4 5 0 5
5 7 1 6
7 9 1 9];
or
A=[
1 2 1 4
3 4 1 4
4 5 1 5
5 7 1 6
7 9 0 9];
댓글 수: 0
채택된 답변
madhan ravi
2019년 9월 19일
편집: madhan ravi
2019년 9월 19일
ix = 1:2:size(A,1);
A(ix(randi(numel(ix),1)),3)=0
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!