필터 지우기
필터 지우기

How to make any math operation when there are NaN in data serial?

조회 수: 6 (최근 30일)
How to make any math operation when there are NaN in data serial?
I'd like to make an test using in my data serial NaN...
For exemplo: I have 2 matrix (a and b) and I'd like of sum them!!!
Ex:
a=[1,2,3,NaN,5]
b=[1,2,3,8,5]
c=(a+b)
How can I to do?
  댓글 수: 2
Image Analyst
Image Analyst 2014년 7월 13일
What value do you want for c(4)?
Carlos Batista
Carlos Batista 2014년 7월 13일
Can be any value!!!
For exemplo: can be these 2 matrix!
a=[0,-10,3,-100]
b=[-1,-2, NaN, -0]
Only want learn as to do!
This model don't I understood
Thanks!
Carlos

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

채택된 답변

Image Analyst
Image Analyst 2014년 7월 13일
편집: Image Analyst 2014년 7월 13일
Try these two different approaches:
a=[1,2,3,NaN,5]
b=[1,2,3,8,5]
cWithNans = a + b % c(4) will = nan
nonNanLocations = ~isnan(cWithNans) % Location of indexes that are good.
cwithoutNans = cWithNans(nonNanLocations)
% c(4) is skipped and new c(4) = old c(5)
  댓글 수: 5
Image Analyst
Image Analyst 2014년 7월 13일
isnan() is a function that is the same length as the array that you pass it. It will be true or 1 where there is a nan in the array, and false or 0 where there is a good number. You can pass that in to the array as an index to extract all the elements of the array that are, or are not, nans.
Carlos Batista
Carlos Batista 2014년 7월 14일
First step I did!!!!
Now, I need to help for know as remove the NaN when I have a matrix as more than 1 dimension (...)
For exemplo
a = 10x8x2,
where, 10 is latitude, 8 longitude and 2 time (...)
I need that there are withdrawal these NaN in a matrix com 3D

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by