Replacing NaN's in column of a Matrix

조회 수: 1 (최근 30일)
Claire Hollow
Claire Hollow 2020년 5월 29일
편집: Stephen23 2020년 5월 29일
Hello! I feel tihs should be rather simply but for some reason I cannot get it to work.
I have a 2922x14 matrix. In random places in the second column there are 'NaN' and I'm trying to change all the 'NaN' to 250. Im trying to do a possible if-else (or anything that should work) statement to change all the NaN in just that second column to 250. Thank you ahead of time for the help!

채택된 답변

Stephen23
Stephen23 2020년 5월 29일
Where M is your matrix:
X = isnan(M(:,2));
M(X,2) = 250;
  댓글 수: 1
Claire Hollow
Claire Hollow 2020년 5월 29일
편집: Stephen23 2020년 5월 29일
Work perfectly, thank you so much!

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

추가 답변 (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