Message Boards Message Boards

GROUPS:

[?] Avoid problem with Units Seconds vs. s?

Posted 5 years ago
5403 Views
|
7 Replies
|
4 Total Likes
|

This ist only my first simple steps to build a computation to dimension an upload service. Even the first steps are not easy. If i am evaluating this:

uploadtime[filesize_, bandwidth_] := (filesize / bandwidth)
uploadtime[UnitConvert[Quantity[12770776, "Bytes"], "Megabits"], 
 Quantity[2.4, "Megabits"/"Seconds"]]

I am getting this:

Quantity[42.5693, "Seconds"]

If I am evaluating this:

Convert[Month, Second]

I am getting this:

2628000 Second

If I am mulitplying both results I am getting:

Second (Quantity[52560000, ("Megabits")/("Seconds")])

What am I doing wrong?

7 Replies

You're mixing two packages, the built-in functionality and the one from (the very old) Units. Try not to use the Units package any more, everything is now built-in, use the functions:

UnitConvert  (*also to 'simplify' *)
Quantity
QuantityMagnitude
Posted 5 years ago

The last evaluates to: Second (Quantity[52560000, ("Megabits")/("Seconds")]) Why is there a Megabits / Seconds and Second as an result. I would expect that Convert[Month, Second] should evaluate to something which is a number of Seconds.

Posted 5 years ago
Convert[Month, Second]
Quantity[20, "Megabits"/"Seconds"]
%1 * %2

Welcome to Wolfram Community! Please make sure you know the rules and how to format code properly, which you can find here: https://wolfr.am/READ-1ST Not formatting your code can make it unusable to other members. Please respect forum rules.

Can you try formatting your code? It's hard to read and I'm not sure I am understanding what you are doing.

You can format your code by highlighting and clicking the "code sample" button. The code sample button is the first button above the text input field:

enter image description here

It looks like you are typing out "Second" by itself instead of typing Quantity[2628000, "Seconds"].

Posted 5 years ago
Needs["Units`"]
Convert[Month, Second]
Out[1] 2628000 Second
Quantity[20, "Megabits"/"Seconds"] * Convert[Month, Second]
Out[2] Second (Quantity[52560000, ("Megabits")/("Seconds")])

I expected to have only one unit of Seconds either Second or s and not both of them

First, you wrote this function:

uploadtime[filesize_, bandwidth_] := (filesize/bandwidth);

You can use this function with Quantities. For example,

uploadtime[
    Quantity[12770776, "Bytes"], 
    Quantity[2.4, "Megabits"/"Seconds"]]

Quantity[42.5693, "Seconds"]

As you can see, there is no need to call UnitConvert. The division operation handles unit conversion automatically.

You mentioned that you also evaluated:

 UnitConvert["Month", "Second"]

 Quantity[2628000, "Seconds"]

Is this correct?

Can you type-out what calculation seems to not be working for you?

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