create a subset of data matrix randomly

1 次查看(过去 30 天)
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 中查找有关 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