Message Boards Message Boards

0
|
10548 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

WolframAlpha results to array

Posted 9 years ago

Hello

I am completely new to the Wolfram Language and I am searching help for a problem. I want to get some air density data for each 1000 meters from WolframAlpha and return these into an array I can export to matlab. I have found a way to get one value from WolframAlpha by:

WolframAlpha["air density 0 meters",{{"Result",1},"NumberData"}]

Now I want to increase by 1000 meters every time and return this into and array such that

rho_a[1] = WolframAlpha["air density 0 meters",{{"Result",1},"NumberData"}]

rho_a[2] = WolframAlpha["air density 1000 meters",{{"Result",1},"NumberData"}] and so on.

Does anyone know a smart way of doing this?

Thank you very much in advance!

Kind regards

Michael

You could always make a function such as:

f[n_]:=WolframAlpha["air density" <> ToString[n] <> " meters",{{"Result",1},"NumberData"}]

But there is a function in a package for this data, which will be easier to use and quicker:

http://reference.wolfram.com/language/StandardAtmosphere/ref/MeanDensity.html

Needs["StandardAtmosphere`"]
Table[MeanDensity[Quantity[i, "Meters"]], {i, 1, 1000, 100}]

If you want to remove the units from the data, use QuantityMagnitude:

Table[QuantityMagnitude[MeanDensity[Quantity[i, "Meters"]]], {i, 1, 1000, 100}]
POSTED BY: Sean Clarke
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