Message Boards Message Boards

2
|
5785 Views
|
1 Reply
|
3 Total Likes
View groups...
Share
Share this post:

Plotting mixed units?

Posted 8 years ago

I am having an issue plotting using units.

I am trying to plot:

Cos[2*?*f*t] 

where f = 55 Hz and t = 0 to 18 ms

With the Following Code

f = Quantity[55.5556, "Hz"]; 
Plot[Cos[2*?*f*t , {t, Quantity[0,"ms"],Quantity[18, "ms"}]

I get a graph with many cycles ~(55*18)

if I plot

Plot[Cos[2*?*f*t , {t, Quantity[0,"ms"],Quantity[0.018, "ms"}]

I get the single cycle and

Plot[Cos[2*?*f*t , {t, Quantity[0,"s"],Quantity[0.018, "s"}]

also gives me 1 cycle.

So the plot function is ignoring the units. However if I don't put any units in for the time I get a blank graph.

How do I get the Plot function to evaluate the units before plotting? is there a better way to enter units for the independent variable?

POSTED BY: Geoffrey Flynn

Seems to be a bug, but you can try make it work like this:

f = Quantity[55.5556, "Hz"];
Plot[Cos[2*\[Pi]*f*Quantity[t, "ms"]], {t, 0, 18}]
Plot[Cos[2*\[Pi]*f*t], {t, Quantity[0, "Seconds"], Quantity[18, "MilliSeconds"]}]

Please also submit as Product Feedback: http://www.wolfram.com/support/contact/email/

POSTED BY: Sander Huisman
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