Quick data interpolation command
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposta accettata
Star Strider
il 27 Ago 2015
I don’t entirely understand what you’re doing, but the interp1 function will likely do what you want.
1 Commento
Stephen23
il 27 Ago 2015
All of MATLAB's interpolation functions can be found here:
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!