Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

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

Manipulate[
  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.
Why?

Manipulate[
  ListLinePlot[{ OutputResponse[discLowPass[T, τ], dataNoise], 
    dataRaw}],
  {{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.

Manipulate[
  Show[{
    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 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 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 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 at 12:23

1 Answer 1

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

 
discard

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.