How can delete matrix randomly?
이전 댓글 표시
y =[1 2 0.075 0.100 0.000 1.000
2 3 0.080 0.110 0.000 1.000
2 4 0.090 0.180 0.000 1.000
3 9 0.040 0.040 0.000 1.000
4 5 0.040 0.040 0.000 1.000
1 6 0.110 0.110 0.000 1.000
5 14 0.090 0.120 0.000 1.000
6 7 0.080 0.110 0.000 1.000
6 8 0.110 0.110 0.000 1.000
7 9 0.110 0.110 0.000 1.000
7 10 0.080 0.110 0.000 1.000
8 12 0.040 0.040 0.000 1.000
1 11 0.110 0.110 0.000 1.000
11 12 0.090 0.120 0.000 1.000
11 13 0.080 0.110 0.000 1.000
13 14 0.040 0.040 0.000 1.000];
I have matrix y and I want to delete 3 rows randomly. To be like this.
How can I do?
y =[1 2 0.075 0.100 0.000 1.000
2 3 0.080 0.110 0.000 1.000
2 4 0.090 0.180 0.000 1.000
4 5 0.040 0.040 0.000 1.000
1 6 0.110 0.110 0.000 1.000
6 7 0.080 0.110 0.000 1.000
6 8 0.110 0.110 0.000 1.000
7 9 0.110 0.110 0.000 1.000
7 10 0.080 0.110 0.000 1.000
1 11 0.110 0.110 0.000 1.000
11 12 0.090 0.120 0.000 1.000
11 13 0.080 0.110 0.000 1.000
13 14 0.040 0.040 0.000 1.000];
채택된 답변
추가 답변 (1개)
It looks like you've deleted rows not columns.
y(randperm(size(y, 1), 3), :) = []; %delete 3 rows at random
y(:, randperm(size(y, 2), 3)) = []; %delete 3 columns at random
댓글 수: 3
KSSV
2019년 4월 1일
y(randperm(size(y, 1), 3), :) = []; %delete 3 rows at random
y(:, randperm(size(y, 2), 3)) = []; %delete 3 columns at random
Guillaume
2019년 4월 1일
Yes, I spotted the mistake straight away.
pongsapak ruangrob
2019년 4월 2일
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!