필터 지우기
필터 지우기

How to avoid or delete Nan values in addtion?

조회 수: 1 (최근 30일)
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar 2018년 10월 10일
편집: Guillaume 2018년 10월 10일
if i have2 matrix
A=[2 NaN ; 3 NaN]
B=[NaN 4 ; NaN 5]
I want C as
[2 4 ; 3 5 ]
edited by guillaume: Nan is not valid in matlab. NaN or nan is.

채택된 답변

madhan ravi
madhan ravi 2018년 10월 10일
편집: madhan ravi 2018년 10월 10일
A=[2 NaN ; 3 NaN] %Edited
B=[NaN 4 ; NaN 5]
A(isnan(A))=0
B(isnan(B))=0
C=[A;B]'
  댓글 수: 3
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar 2018년 10월 10일
편집: Shubham Mohan Tatpalliwar 2018년 10월 10일
Can i change Nan values to zero and then add both matrices?
that would be more clearer and easier i guess?
madhan ravi
madhan ravi 2018년 10월 10일
Check the edited code

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

추가 답변 (1개)

Guillaume
Guillaume 2018년 10월 10일
If I understood correctly,
C = sum(cat(3, A, B), 3, 'omitnan')

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by