Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'BodePlot using Hertz instead of radians/sec' topicStudent Support Forum > General > "BodePlot using Hertz instead of radians/sec"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
06/08/12 2:28pm

You have: frequencyTicks = N[Map[{#,#/(2 Pi)}&, 10^Range[-1,1,1/3]],1]

We take this apart, look at the individual pieces and then gradually assemble it back together until we understand all of it.

First: Evaluate 10^Range[-1,1,1/3] and see that you get a list of powers of ten. You can try changing the -1, the 1 and the 1/3 and evaluate this each time until you see how that behaves. Those are going to be connected with the values used for your Ticks.

Next: Believe it or not, {#,#/(2 Pi)}& is one strange Mathematica way of writing a function. The # acts like the x in f[x] so whatever value you are going to find the function of the # is going to have that value. Now this function is {#,#/(2 Pi)} and that is saying that the result is a list because of the { and } and the list will have two items in it, the # and the #/(2Pi). So if you try to do that function with 1 then you will get back {1,1/(2Pi)}, with 3.6 you will get {3.6,3.6/(2Pi)}, etc. The & says this is the end of the function definition.

Next: Where do the values come from that are given to this function? Map[afunction,alist] will take each element out alist and give them to afunction and then create a new list of all the results. So that list of powers of ten that we started with are going to be given to that funny function, that funny function is going to return a list of pairs and then all those lists of pairs will be made into a big list of pairs.

Next: N[anyexpression,1] will take the expression, which may have fractions in it, and will turn it into decimals with 1 digit of precision. That means your Ticks won't have fractions and shouldn't have 6 or 16 digits after the decimal point.

Next: You try to see how all these pieces come together.

You can write anything in Mathematica at least a dozen different ways, at least several of which will be nearly incomprehensible.

Here is a different way of writing the same thing.
myTickValues = 10^Range[-1,1,1/3];
myTickFunction[x_] := {x,x/(2 Pi)};
myTicks = Map[myTickFunction,myTickValues];
myRoundedTicks = N[myTicks,1];
frequencyTicks = myRoundedTicks;

If any part of this isn't clear the post a reply and describe how much progress you have made understanding this, where you are stuck and what you need to see next

URL: ,

Subject (listing for 'BodePlot using Hertz instead of radians/sec')
Author Date Posted
BodePlot using Hertz instead of radians/sec Ed Nowak 06/08/12 02:45am
Re: BodePlot using Hertz instead of radians/sec Bill Simpson 06/08/12 2:28pm
Re: Re: BodePlot using Hertz instead of radians... Ed Nowak 06/11/12 03:24am
Re: BodePlot using Hertz instead of radians/sec yehuda 06/09/12 05:27am
Re: Re: BodePlot using Hertz instead of radians... Ed Nowak 06/11/12 03:45am
Re: BodePlot using Hertz instead of radians/sec Bill Simpson 06/09/12 11:25am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic