필터 지우기
필터 지우기

Quick data interpolation command

조회 수: 3 (최근 30일)
Giovanni
Giovanni 2015년 8월 27일
댓글: Stephen23 2015년 8월 27일
Hello,
I wanted to ask if there is any function developing a quick data interpolation, when already having a vector containing the grid of values to interpolate between. I have a vector of about 200 points, representing a certain function. Then I have another array, and I want to use them as values of the x-axes to interpolate through my 200 points grid which are values of the y-axes. At the moment I have built up a for loop that starts from the beginning of the x axes, finds all the values between two consecutive grid values, and makes a linea interpolation between the two points of the grid for all the identified points:
for i = 1:length(net)-1
j{i} = find(Pin >= net(i) & Pin < net(i+1));
m_main = (grid(i+1,1) - grid(i,1))/(net(i+1) - net(i));
q_main = grid(i+1,1) - m_main*net(i+1);
Pmain(j{i}) = m_main*Pin(j{i}) + q_main;
end
grid, is actually a matrix containing the y values (ordered), and net is the x coordinate for those values. I use pairs of consecutive values in order to compute the steepness of the linear conjunction between the two points, and the elevation. Then I simply modify all the values by the linear approximation with the classic y = m*x + q formula.
Now, since I seem to have some problems with my script (apparently changes the order of some data points in the final result), I was wondering if MATLAB is already offering some functions to obtain this quickly and properly.
Any tipp?
Best Regards, Giovanni

채택된 답변

Star Strider
Star Strider 2015년 8월 27일
I don’t entirely understand what you’re doing, but the interp1 function will likely do what you want.

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