I'm trying to create a pure function that I can feed into OutputResponse[ ] as the input u[t]. In order to do this, I've written code to create a square wave pulse train in the form of a collection of (x,y) points. This is created from two lists: a list of y values ("vVect") and a list of x values ("tVect"). In trying to use Interpolation[ ] (and ListInterpolation[ ]), I am getting back functions that behave different than the set of points they interpolate. Is this just a problem with Mathematica's plotting function? What I want is something that looks exactly like the ListLinePlot, but that I can assign to the function u, as I can't pass a set of points to OutputResponse[ ].

pTrain = Partition[Riffle[tVect, vVect], 2];     


u = ListInterpolation[vVect, {{0, 0.002}}, InterpolationOrder -> 0]
Plot[u[t], {t, 0, 0.002}]

Plot of interpolation function


closed as off-topic by m_goldberg, Feyre, Wjx, MarcoB, gwr Sep 8 '16 at 6:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Feyre, Wjx, gwr
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Mar 5 '15 at 21:14
  • $\begingroup$ Please provide at a manageable portion of tVect and cVect, so that your computations can be reproduced. $\endgroup$ – bbgodfrey Mar 5 '15 at 21:17
  • $\begingroup$ Sorry! tVect:<dropbox.com/s/2pqygz5sfc030o1/tVect.dat?dl=0> vVect: <dropbox.com/s/7nuws5kusoxaxrn/vVect.dat?dl=0> $\endgroup$ – everson Mar 5 '15 at 21:31

You just need more PlotPoints:

tVect = Get["tVect.dat"] ;
vVect = Get["vVect.dat"] ;
pTrain = Partition[Riffle[tVect, vVect], 2];
f = Interpolation[pTrain, InterpolationOrder -> 0] ;
Plot[f[s], Evaluate[Join[{s}, First[f["Domain"]]]], PlotPoints -> 200]

Not the answer you're looking for? Browse other questions tagged or ask your own question.