Message Boards Message Boards

GROUPS:

[✓] Use Iterator in a table containing a plot function?

Posted 2 months ago
316 Views
|
2 Replies
|
0 Total Likes
|

In the following program, I want to generate four graphs by iterating the variable n and plotting the results as a 2 X 2 grid. The iterator does not seem to be working as expected even though it is in the correct format {n, nmin, nmax, dn}. The code completes the first iteration when n=5, but it does not finish for the other values of n. Where in my syntax is the problem?

Attachments:
2 Replies
Posted 2 months ago

Try this

graphs = Table[Plot[{x, Evaluate[f[x, n]]}, {x, 0, \[Pi]}, 
    Ticks -> {{0, \[Pi]}, {1, 2, 3}}], {n, 5, 35, 10}];

Evaluate is needed because Plot has the HoldAll attribute.

Attributes[Plot]
(* {HoldAll, Protected, ReadProtected} *}
Posted 2 months ago

Thanks

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