필터 지우기
필터 지우기

Select some elements from a given matrix

조회 수: 2 (최근 30일)
Cladio Andrea
Cladio Andrea 2015년 3월 25일
편집: James Tursa 2015년 3월 25일
Hello everyone, I have a matrix something like
m=[0.34,0.000009,0,2, 0,0.4,0.00087];
what i want is to pick randomly 3 elements from that matrix, i am really stuck , can anyone help?

채택된 답변

James Tursa
James Tursa 2015년 3월 25일
편집: James Tursa 2015년 3월 25일
Assuming you don't care about the order in which they are selected:
m(randperm(numel(m),3))
If you want to preserve the original ordering, then:
m(sort(randperm(numel(m),3)))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by