Interpolation in mat-lab

조회 수: 2 (최근 30일)
Maayan
Maayan 2013년 9월 10일
Hi, I have a vector with different values. Some of the values are zeros and sometimes they even come one after another. I need to plot this vector against another vector with the same size but i can't have zeros in it. What is the best way i can do some kind of interpolation to my vector and how do i do it? Thanks
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 10일
Give a short sample of your data, and explain what is the problem

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

채택된 답변

Simon
Simon 2013년 9월 10일
Hi!
What kind of interpolation do you need? Try "interp1"!
  댓글 수: 2
Maayan
Maayan 2013년 9월 10일
I don't even have any idea what kind of interpolations are. My vector has intensities values of an image and eventually i will need to plot it against the time that the video lasts. I have some zeros there because in the video there are some blank frames and i don't want the plot to address them. What kind of interpolation do you think will be best here? I will also appreciate if you can explain me how to use the "interp1", i read about it but didn't understand it good enough to implement it. I'm very new with the program. thanks
Simon
Simon 2013년 9월 10일
Hi!
You have the time stamps of your frames, these are the "xi". Your "x" values are the time stamps where the frames are not blank. The "Y" are the non-zero values of your vector.
% vector of frames
vec = [1 5 6 3 0 4 0 5 7 0 3];
% set vector of time staps, fill in your values
xi = [1 2 3 4 5 6 7 8 9 10 11];
% get non-blank frames, fill in your vector values
nonblankframe = find(vec > 0);
% vector to interpolate
Y = vec(nonblankframe);
% time stamps of non blank frames
x = timestamps(nonblankframe);
% interpolate
yi = interp1(x,Y,xi);

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

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