Comparing values of 2 vectors and extracting rows from a matrix corresponding to matching value locations.

1 view (last 30 days)
I'm doing a curve fitting problem in Matlab and so far I've set up some orthonormal polynomials along a specified range of x-values with x = (0:0.0001:40);
The polynomials themselves are each a manipulation of that x vector and are stored as a row in a matrix. I also have some have data entries in the form of two vectors - one for the data x-coords and one for the actual values. I need a way to use the x-coords of my data points to find the same values in my continuous x-vector and then take the corresponding columns from my polynomial matrix and add them to a new matrix.
EDIT: To be more clear. I have, for example, a range of x values in a vector as [0 1 2 3 4 5] from which I've made a vector with the values of y = x^2 -1 which is [-1 0 3 8 15 24]. I also have some actual data values with x-coords in a vector [1 3 4] with corresponding values of [5 3 8]. In order to calculate the difference between my y = x^2 - 1 line and the measured data I need just the columns where the x-values match up. So I want to change the [-1 0 3 8 15 24] to [-1 3 8] but without knowing which columns I'll need beforehand.

Answers (0)

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!