# Interpolate to fill missing values in a temperature Matrix by considering the altitude (stored in a separate matrix)

11 views (last 30 days)

Show older comments

Dear all,

I have got a matrix with temperatures (let's call it T), and a matrix with altitudes (let's call it Z). They're both 150x150.

T contains some missing values that I need to fill.

Rather than filling it with a basic linear interpolation, I need to fill it taking into account the altitude (Z).

Could you please suggest a code to fill the missing values in T weighted on Z?

Thanks a lot!

##### 2 Comments

dpb
on 30 Apr 2023

### Answers (1)

Image Analyst
on 3 May 2023

What exactly does "missing" mean to you? You can't have "holes" in the matrix. The values must either be nan, 0, or some other value.

help interp2

##### 5 Comments

Mathieu NOE
on 7 May 2023

hello again

before you do the interpolation with interp1 , you have to make sure that the data (Zrow,Trow) are unique

use unique to remove duplicates

dpb
on 7 May 2023

"...with interp1 , you have to make sure that the data (Zrow,Trow) are unique"

The functional also cannot be double-valued, so if your data follow the terrain up and down, that doesn't work, either.

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!