필터 지우기
필터 지우기

create a subset of data matrix randomly

조회 수: 2 (최근 30일)
KAKOLI DEY
KAKOLI DEY 2018년 5월 22일
댓글: Jan 2018년 5월 22일
i have a complete matrix of dimension 116X17. I need a half of the elements ie 896 elememens of the matrix are created randomly with all other cell have NaN value.
  댓글 수: 1
Guillaume
Guillaume 2018년 5월 22일
편집: Guillaume 2018년 5월 22일
What does created randomly mean? What range of values should be created?
What is the point of the original matrix, if your new matrix is either completely random numbers or NaN?

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2018년 5월 22일
A = rand(116,17) ; % your data
N = 896 ;
iwant = NaN(size(A)) ;
idx = randperm(numel(A),N) ;
iwant(idx) = A(idx) ;
  댓글 수: 2
KAKOLI DEY
KAKOLI DEY 2018년 5월 22일
your answer is partially fulfill my requirement ,Random geneneration of NaN values are OK,I want generate matrix original value instead of random number.
Jan
Jan 2018년 5월 22일
@KAKOLI DEY: Then use your original matrix instead of A. The rand was used here only to create example data.
@KSSV: +1.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by