Raspberry PI using Mathematica/wolfram alpha on command-line

install the program on your pi using
sudo apt-get update && sudo apt-get install wolfram-engine

after some minutes and the complete installation you can start the command-line part of wolfram with
wolfram

to exit the program (case sensitive!!)
Quit[]

get the version $Version
from (1): get all  Export[„PiFuncs.dat“,Names[„System`*“]]

documentation of wolfram language at (2)

little sample of a shell-script

create a file called date.m and paste the following into it
Export[„Date.txt“,DateList[]]
to run the script do
wolfram -script date.m
now you should see the file Date.txt with your current date.

render graphics (3)

to render graphics install xvfb
sudo apt-get installt xvfb
to run a 24bit emulator start wolfram with
xvfb-run -s „-screen 0 640x480x24“ /opt/Wolfram/WolframEngine/10.0/Executables/math
or if you want 8 bit graphics:
xvfb-run -s „-screen 0 640x480x8“ /opt/Wolfram/WolframEngine/10.0/Executables/math

p=DensityPlot[{Sin[Sqrt[x] + Log[y]]}, {x, 0, \[Pi]^2}, {y, 0, E^\[Pi]}]
Export[„testplot24.png“,p]

EdgeDetect und Colorize
i=Import[„p.png“]
g=Colorize[MorphologicalComponents[EdgeDetect[i]]]
Export[„plot.png“,g]

TextRecognize[i]
No solution found for the error
TextRecognize::langinv: Language file for eng could not be found.

Working with Lists

Get data from wolfram-alpha like
e=WolframAlpha[„elevation around vienna“]

This gives you 3 Lists containing data.
With length you can count the number of lists in e
Length[e]
3

Get the first element with (or the last element Last[e])
First[e]
To get the second element do Take with from=2 and to=2 variables
Take[e,{2,2}]
To see element one and two do one of those
Take[e,{1,2}]

Take[e,2]

Import / Export

here are different export-formats for graphics and sounds (4)

get data from html
import[„URL“]

LocationData

eg. with CityData[…] you can query lots of information about cities
First PI loads data from the wolfram-server (this takes quite a while) but then 🙂
CityData[„Wien“] gives you all woldwide cities called Wien
Out[4]= {{Vienna, Vienna, Austria}, {Vienna, Virginia, UnitedStates},
Getting the geo-coordinates
In[18]:= CityData[{„Wien“,“Austria“},“Coordinates“]
Out[18]= {48.22, 16.37}

i love that!!

Other data-bases are e.g.: CountryData, RiverData, DesertData (woooo)
To compute the distance do (result is in meters)
In[20]:= GeoDistance[CityData[{„Wien“,“Austria“},“Coordinates“],CityData[{„Bregenz“,“Austria“},“C
oordinates“]]
Out[20]= 502871.

Sunset and Sunrise

get astronomical infos like sunset/sunrise
WolframAlpha[„Sunrise Vienna“]

infos and links

Advertisements

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s