Group Abstract Group Abstract

Message Boards Message Boards

0
|
347 Views
|
6 Replies
|
5 Total Likes
View groups...
Share
Share this post:

How to set X or Y axis units to engineering notation (display uV or ms etc)

Posted 15 days ago

Hello, I have a two part question.

(1) I am trying to plot engineering waveforms, where the y-axis or x-axis or both may be in engineering notation. Is there a way to automatically format the axes to show the values in engineering format (e.g., uV for y-axis in this example code attached. or ms (milli second) for time axis.

(2) I am calculating the power and energy using the given voltage and current values. However, the plot for the energy (w variable) is not formatted correct and the x-axis information is not matching the x-axis information for the previous three plots. Is there a way to fix that? I realise that its plotting the indice as x-axis variable and somehow that needs to be scaled back to time information. I have tried various things but unable to fix it.

Any help would be greatly appreciated regarding the two plotting issues. Thanks

POSTED BY: ok ok
6 Replies
Posted 14 days ago

Thank you. In your suggestion, is there a way to associate x-axis variable t with time (seconds). I tried but the code does not work them if I use Quantity on t.

POSTED BY: ok ok

You are right, it does not seem to work on the horizontal axis:

Plot[UnitSimplify[t*Quantity[3, "Watts"]], {t, Quantity[-1, "Seconds"],
   Quantity[1, "Seconds"]}, AxesLabel -> Automatic]
POSTED BY: Gianluca Gorni
Posted 13 days ago

Thank you for sharing your expert knowledge. You given command syntax works. I have tried to adapt it when the y-axis quantity is defined as a function but it runs into syntax errors and no value is plotted.

In the attached code, the first plotting command (when time is not defined as a second quantity) works. But the second plotting command does not work.

I will be extremely thankful if you can suggest how to fix this!

POSTED BY: ok ok

The way you have defined v[t], it accepts only pure numbers as t, not quantities. Also, UnitSimplify[Quantity[v[t]], "Volts"] is incorrect, try with the very convoluted Quantity[v[QuantityMagnitude[t, "Seconds"]], "Volts"], which purifies t before feeding it to v.

POSTED BY: Gianluca Gorni
Posted 12 days ago

Thank you so much for sharing your expert knowledge of Mathematica. The problem is solved!

POSTED BY: ok ok

One way is to use FrameLabel, possibly with Quantity:

Plot[Quantity[t^2, "Watts"], {t, -1, 1},
 Frame -> True,
 FrameLabel -> {{Automatic, None}, {None, None}}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard