필터 지우기
필터 지우기

Replacing 0 with NaN by indexing into a matrix

조회 수: 4 (최근 30일)
Jenny
Jenny 2013년 9월 26일
편집: Azzi Abdelmalek 2013년 9월 26일
I have a data matrix called 'data' of 84761 x 11. (a small selection of the data is attached).
I am able to allocate column variable into arrays e.g. column 10 = WindDirec with DD1 = data(:,10).
I can then replaces the 0 values with NaN by: DD1(DD1==0)=NaN.
Is there a way to do this without first assigning column variables to arrays? I would like to index into the matrix 'data' and replaces all 0 values in column 10 with NaNs.
data(data(:,10)==0)=NaN; replaces the values in the first column with NaN, given by the index provided by where column 10 = 0;
How do I index to column 10 to then replace the 0's with NaNs?
Thank you Jenny

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 26일
편집: Azzi Abdelmalek 2013년 9월 26일
data(data(:,10)==0,10)=nan

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by