Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok, I think this is not the best way to do this, so I'm open minded for every suggestion doing it in a better way.

The Question is why does ListLinePlot not plot all the data when it's inside Manipulate?

I created a dataset w/ and wo/ noise:

dataFunc[x_] := .5 Sin[x^2 + x]

dataRaw = Table[dataFunc[x], {x, 0, 2 π, .001}];
dataNoise = 
  Table[dataFunc[x] + RandomReal[{-1, 1}], {x, 0, 2 π, .001}];

Grid[{ListLinePlot /@ {dataRaw, dataNoise}}]
ListLinePlot[{dataNoise, dataRaw}]

dataset wo/ and w/ noise

I'm doing the built in low-pass filter with Manipulate

  ListLinePlot[{LowpassFilter[dataNoise, ω, n], dataRaw}],
  {{ ω, .3}, .001, Pi, .001}, {{n, 100}, 1, 500, 1}]

enter image description here

Now I added my own low-pass filter:

discLowPass[T_, τ_] := 
  ToDiscreteTimeModel[ TransferFunctionModel[ 1/(1 + T s), s], τ]

And here it is: Without the dataRaw it works

  ListLinePlot[OutputResponse[discLowPass[T, τ], dataNoise]],
  {{T, .1}, .005, 25}, {{ τ, .005}, .001, .025}]

enter image description here

... but adding the signal without noise to the ListLinePlot it doesn't work anymore.

  ListLinePlot[{ OutputResponse[discLowPass[T, τ], dataNoise], 
  {{T, .1}, .005, 25}, {{ τ, .005}, .001, .025}]

enter image description here

It's just plotting the raw signal without the noise.

EDIT: Using Show it works for the OutputResponse, too.

    ListLinePlot[OutputResponse[discLowPass[T, τ], dataNoise]],
    ListLinePlot[dataRaw, PlotStyle -> Red]}],
  {{T, .25}, .005, 5, .005}, {{ τ, .01}, .001, .025}]

enter image description here

share|improve this question
What you are actually plotting in the end is ListLinePlot[dataRaw] – Öskå Apr 14 '14 at 12:05
@Öskå That's what I can see, yes, but what is with the Outputresponse? In the first case with LowpassFilter[] it works too, doesn't it? – Phab Apr 14 '14 at 12:12
The problem here is that Manipulate[ ListLinePlot[{OutputResponse[discLowPass[T, \[Tau]], dataNoise]}], {{T, .1}, .005, 25}, {{\[Tau], .005}, .001, .025}] is not being plotted for some reason. – Öskå Apr 14 '14 at 12:15
@Öskå ... and the question is why is it not plotted, while it is plotted when I take the built in LowpassFilter instead of the OutputResponse. – Phab Apr 14 '14 at 12:23
up vote 4 down vote accepted

Like noted in the comments the problem is that

Manipulate[ListLinePlot[{OutputResponse[discLowPass[T, τ], dataNoise]}],
             {{T, .1}, .005, 25}, {{τ, .005}, .001, .025}]

enter image description here

doesn't work while the following works:

Manipulate[ListLinePlot[OutputResponse[discLowPass[T, τ], dataNoise]],
             {{T, .1}, .005, 25}, {{τ, .005}, .001, .025}]

enter image description here

By looking into OutputResponse[] you can see that it's built as follow:

OutputResponse[discLowPass[0.1, 0.5], dataNoise] // Short

{{-0.203869, -0.311799, -0.725601, <<6278>>, 0.765344, 1.17987, 0.143347}}

and that it's a {1, 6284} array.

Thus the following works:

Manipulate[ListLinePlot[{First@OutputResponse[discLowPass[T, τ], dataNoise], dataRaw}], 
             {{T, .1}, .005, 25}, {{τ, .005}, .001, .025}]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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