필터 지우기
필터 지우기

How to select common data in two different variables

조회 수: 2 (최근 30일)
Abhishek Savita
Abhishek Savita 2018년 4월 30일
댓글: Abhishek Savita 2018년 5월 1일
Dear matlabers I have two variables with dimensions (lat,lon,time), var1 is for depth 300 and var2 for depth 700. I want to add these two variables but I do not have the data in the same location in both variables i mean some has Nan value.
So i want to add the variables where we have data in the same location in both variables other discarded.
any help will appreciated
  댓글 수: 4
Wick
Wick 2018년 5월 1일
Can you give us a bit of code or some numbers as an example? Adding NaN's to finite values results in a NaN so you may just be able to pad the shorter vector to match the length of the longer vector (with NaN's) and then add them together.
Example: V1 = [1 2 NaN 4]; V2 = [1 NaN NaN 5 NaN NaN]
If you pad V1 with two NaN's at the end you can just get the result: V1+V2 = [2 NaN NaN 9 NaN NaN]
Is this along the lines of what you're looking for?
Abhishek Savita
Abhishek Savita 2018년 5월 1일
Thank you Chad for your advice and its work.

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

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