Mathematica Asked on August 22, 2021
I’d like to plot something like this:
Except that instead of manually specifying all the functions to be plotted, I specify a range
. So for example I could feed the command Range[0,6,2]
to get it to plot four lines on the same plot, i.e. $mathrm{Sin}[0],mathrm{Sin}[2x],mathrm{Sin}[4x]$ and $mathrm{Sin}[6x]$.
How can I do this? I tried Plot[Sin[# x], {x, 0, 2 Pi}] & /@ Range[1, 3]
which yields the desired three lines, but each in their own plot as opposed to one. Attempting to map twice with Plot[#, {x, 0, 2 Pi}] & /@ {Sin[# x] /@ Range[1, 3]}
yields no plot at all.
Plot[Sin[# x] & /@ Range[1, 3] // Evaluate, {x, 0, 2 Pi}]
Correct answer by cvgmt on August 22, 2021
Try Show
to combine the plots
Show[Plot[Sin[# x], {x, 0, 2 Pi}] & /@ Range[1, 3] ]
or
Plot[Table[Sin[om x], {om, Range[1, 3] }] // Evaluate, {x, 0, 2 Pi}]
Answered by Ulrich Neumann on August 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP