John
John

Reputation: 71

How to replace rows in a table with 'NaNs', leaving the matrix dimension unchanged? (Matlab)

Let's assume the following:

A=rand(10,5);

How can I replace the first 3 rows of this table with NaN's, without the matrix losing its original dimension 10x5? Thanks in advance

Upvotes: 1

Views: 44

Answers (1)

rayryeng
rayryeng

Reputation: 104555

Just index into the first three rows but ensure you select all of the columns and replace the entries with nan:

A(1:3,:) = nan;

I have a minor comment. The variable A is not a table, but it is a matrix. Please ensure you use the right terminology from now on, as someone may confuse what you're saying with the actual table construct.

Upvotes: 2

Related Questions