matlab - How do I "stretch" (interpolate) an array but keep its underlying data intact? -
i have 2 splines i've generated (a bit of modification of) getcurve() represent xy , xz of trajectory. combine 2 splines generate 3d plot, via plot3(). modified getcurve() output xdata , ydata of line drawn on plot.
since splines graphically generated, number of elements won't same between xy , xz. suppose length(xy)>length(xz). i'm trying create new vector xz_2 has same length xy , has same x-values xy.
my first idea interpolate follows:
xz_2(:,2) = interp1(xz(:,1), xz(:,2), xy(:,1)) but error:
error using griddedinterpolant grid vectors not strictly monotonic increasing. error in interp1 (line 191) f = griddedinterpolant(x,v,method); the spline xz looks this:

i don't understand why can't interpolate given spline. doesn't special. can rebuild spline doing following (you'll need curve fitting toolbox):
>> xz = [0.0288 0.0518 0.1071 0.1763 0.2707 0.3583 0.4988 0.5864 0.7339 0.8191 0.9182 0.9781 1.8070 1.3626 0.9766 0.4152 -0.0643 -0.3684 -0.9181 -1.1637 -1.4795 -1.6667 -1.8070 -1.9474]; >> fnplt(cscvn(xz)); is there way "resize" xz use same x-values xy? realize information xz lost when this, that's okay.
it says in interp1(x, y, xi);, x , xi must monotonic increasing, i.e. sorted.
Comments
Post a Comment