I am looking for a solution to insert a different number of NaNs into the first rows of a matrix. Let's assume I have a 20x3 double matrix and a 1x3 double row vector called numNaNs. The row vector contains the number of NaNs that I would like to insert into the matrix.
For example, let's assume numNaNs = [3, 5, 7]. What would the code looks like to replace the first 3 rows of column 1 in the matrix with NaNs, as well as the first 5 rows of column 2 in the matrix, and the first 7 rows of column 3 in the matrix?
I tried something like this:
mat(1:numNaNs, :) = nan;
However, this only replaces the first 3 rows in all columns with NaNs.