creating an empty cell in an array

조회 수: 5 (최근 30일)
Ahmed Abdulla
Ahmed Abdulla 2019년 6월 21일
댓글: Akshay Malav 2019년 6월 21일
i have an array most made up of numbers and some are NaN i would like to make the NaN cells empty because i have a plotting function that doesnt accept NaN and when i assign it to 0 it affects the resulting graph, so im not really sure of how to make it blank with no numerical value
  댓글 수: 4
madhan ravi
madhan ravi 2019년 6월 21일
Can’t you just ignore NaN values using isnan() ?
madhan ravi
madhan ravi 2019년 6월 21일
a = [1,2,NaN,5,NaN]
b = [3,4,5,1,NaN]
result = ???

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

채택된 답변

Akshay Malav
Akshay Malav 2019년 6월 21일
편집: Akshay Malav 2019년 6월 21일
Then use this code.
A = [1 NaN 2];
B = rmmissing(A) % will remove NaN from array A
The B array wil be [1 2]
  댓글 수: 2
Ahmed Abdulla
Ahmed Abdulla 2019년 6월 21일
the problem with this is that im plotting 2 different arrays where Nan in one array might be an actual value on the other so this will make the data miss match
Akshay Malav
Akshay Malav 2019년 6월 21일
Then you can ignore the corresponding values in the second array .

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by