create a subset of data matrix randomly

1 Ansicht (letzte 30 Tage)
KAKOLI DEY
KAKOLI DEY am 22 Mai 2018
Kommentiert: Jan am 22 Mai 2018
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 Kommentar
Guillaume
Guillaume am 22 Mai 2018
Bearbeitet: Guillaume am 22 Mai 2018
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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 22 Mai 2018
A = rand(116,17) ; % your data
N = 896 ;
iwant = NaN(size(A)) ;
idx = randperm(numel(A),N) ;
iwant(idx) = A(idx) ;
  2 Kommentare
KAKOLI DEY
KAKOLI DEY am 22 Mai 2018
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 am 22 Mai 2018
@KAKOLI DEY: Then use your original matrix instead of A. The rand was used here only to create example data.
@KSSV: +1.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by