merging two matrices (cell matrices)

조회 수: 1 (최근 30일)
ARS
ARS 2013년 9월 7일
Hi,
I have two cell matrices with same dimensions (63,820)
for each cell of Matrix AA there is a corresponding numeric value in same location cell of Matrix BB. However, there are many instances where Matrix BB has NaN values.
I wish to have a Matrix CC which should be exactly same as Matrix AA but it should replace/swap its cell's contents to 'NaN' if the corresponding value of the same location cell in BB is a NaN.
Any body with a short code?
All help will be appreciated.
Regards,
AMD.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 7일
편집: Azzi Abdelmalek 2013년 9월 7일
AA={1 2 3;4 5 6;7 8 9}
BB={10 nan 2;nan 5 55;nan 44 66}
CC=AA
CC(cellfun(@isnan,BB))={nan}
  댓글 수: 1
ARS
ARS 2013년 9월 7일
Thanks a lot Azzi....Appreciate your help.

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

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