Message Boards Message Boards

GROUPS:

Plotting two graphs together and doing manipulation

Posted 4 months ago
399 Views
|
2 Replies
|
0 Total Likes
|

I need help in plotting two graphs together and doing some sort of manipulation. I have a sequence:

A=ListPlot[List, PlotRange -> {{0, 201}, {-0.01, 0.01}}]

, where

List=Table[a[n], {n, 200}] and a[n_]=(-1)^n/n^2

And I need two parallel lines which can be manipulated, so I have written sth like that, but I am not sure if it is correct:

B[z_] = Plot[{z,-z}, {x, 0, 200}, Filling -> {1 -> {2}}]

And I have written such a command to plot A and B and to be able to change values of 'z':

Manipulate[Show[A, B], {z, 0.000001, 0.02}]

But unfortunately, it doesn't work. It drew only a Listplot and skipped B. Where did I make a mistake?

2 Replies
Posted 4 months ago

Kamil,

There are several issues with the code. Study the difference between = and := here. Do not assign values to built-in symbols like List. It is best to start names with a lower case letter to avoid conflicts.

a[n_] := (-1)^n/n^2;

data = Table[a[n], {n, 200}];

plotA := ListPlot[data, PlotRange -> {{0, 201}, {-0.01, 0.01}}]

plotB[z_] := Plot[{z, -z}, {x, 0, 200}, Filling -> {1 -> {2}}]

Manipulate[Show[plotA, plotB[z]], {z, 0.000001, 0.02}]

enter image description here

Thank you very much for your help :)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract