From: Michael on 8 Jul 2010 09:45 MATLAB Version 7.10.0.499 (R2010a) I need help understanding how the interp1 function works. I have looked at the documentation (in particular example 1see below), and website (still working through all of these) and it still have not found an answer to my questions. I have varied the step of xi to values larger and smaller than x see example. When I plot the results for xi step of 2 it skips over every other point. However, with a value smaller than 1 (x step) the interval of xi is the default of x (in this case one). So here is the question: How is this a finer abscissa?? What do I not understand? -------- interp1 example 1 Generate a coarse sine curve and interpolate over a finer abscissa. x = 0:1:10; y = sin(x); xi = 0:0.5:10; %xi = 0:2:10; %larger step size than x yi = interp1(x,y,xi); plot(x,y,'o',xi,yi)
From: John D'Errico on 8 Jul 2010 09:58 "Michael" <michael.lisowski(a)gentex.com.extrachar> wrote in message <i14kp4$lh1$1(a)fred.mathworks.com>... > MATLAB Version 7.10.0.499 (R2010a) > > I need help understanding how the interp1 function works. I have looked at the documentation (in particular example 1see below), and website (still working through all of these) and it still have not found an answer to my questions. I have varied the step of xi to values larger and smaller than x see example. When I plot the results for xi step of 2 it skips over every other point. > However, with a value smaller than 1 (x step) the interval of xi is the default of x (in this case one). > I have no idea what you mean by this last statement. Please show an example, because I can only guess that you have made a mistake in your code. > So here is the question: How is this a finer abscissa?? What do I not understand? When you show what is confusing you, then we can help. > -------- > interp1 > example 1 > Generate a coarse sine curve and interpolate over a finer abscissa. > > x = 0:1:10; > y = sin(x); > xi = 0:0.5:10; > %xi = 0:2:10; %larger step size than x > yi = interp1(x,y,xi); > plot(x,y,'o',xi,yi) When diff(xi) is smaller than diff(x), the abscissa might be said to be finer. John
From: Michael on 8 Jul 2010 10:14 Sorry, I figured out my issue in the example x = 0:10; y = sin(x); xi = 0:.25:10; yi = interp1(x,y,xi); plot(x,y,'o',xi,yi) The plot generated a perficly straight line between the (x(1),y(1)) and (x(2),y(2)). With the value interpelated value of yi egual to exactly half of y(2). Hence, a linear interpolation. This example may have been better off if they had used yi = interp1(x,y,xi,'spline');
|
Pages: 1 Prev: Parallel or distributed plotting Next: SIMSCAPE: Different sets of domain parameters |