Simple Linear Interpolation using Interp1

조회 수: 174 (최근 30일)
Michael
Michael 2014년 8월 14일
댓글: Peter 2024년 4월 23일 12:54
Hi all. I'm fairly new to Matlab and I'm just trying to interpolate.
I have a [1 12] time vector that represent 12 hours. I also have a temperature vector that only has 10 values because 2 of them are missing. I understand that the sizes must be equal to use interp1. This is what I have so far:
time = [1 2 3 4 5 6 7 8 9 10 11 12];
temp = [10 12 15 13 [] 16 16 18 [] 15 21 20];
points = [1 2 3 4 5 6 7 8 9 10 11 12];
y = interp1(time,temp,points,'linear')
The empty matrices are where I don't have available times. I'm trying to use all of this data to linearly interpolate temperatures for all entries in my points array.
Thanks so much :)

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 8월 14일
편집: Andrei Bobrov 2014년 8월 14일
time = [1 2 3 4 6 7 8 10 11 12];
temp = [10 12 15 13 16 16 18 15 21 20];
points = [1 2 3 4 5 6 7 8 9 10 11 12];
y = interp1(time,temp,points,'linear');
  댓글 수: 5
Gem
Gem 2022년 11월 19일
May I have a question, is it possible to interpolate the data (NaN) if the x and y does have the same length in 3D plot.
Thank you !
Peter
Peter 2024년 4월 23일 12:54
Thank you from 10 years later!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by