Hot answers tagged

26

Certainly. There have indeed been some changes to certain tags in the 2.1 API and also to the method to sort out how many pages to import. And, since we are now a full site under StackExchange, the server has changed and a site parameter was necessary. I did a bit of clean-up, hardened the code a little to accommodate connection failures, made the basic ...


24

Yes it is possible, but it is not natively supported. Therefore, the way through ImageCapture will not work here. Nevertheless, no one prevents you to use a library like opencv to access the webcam. With a MathLink wrapper you can write a routine to catch frames from the cam and transfer them as Image to Mathematica. When opencv is initialized and has ...


24

In the comments mfvonh correctly points out that the Wikimapia's URL in my question is a user interface URL, not a tile server URL. The tile server link template is documented in a message which appears when one sends incorrect request to the tile server: From the above it is clear that the StringTemplate should be as follows: ...


19

There is a neat application called Tasker, which allows for the automation of scripts (tasks) on the android phone, triggered by events, time or phone state changes. In this example, we'll simulate the "It's just metadata" approach by capturing some phone variables and pushing the values into the new DataDrop Universal accumulator via the web api. ...


18

Let's invent some data. The pulse rate will be 50 pulseRate = 50; sampleRate = 1000; data = Range[0, 1, 1/sampleRate] /. t_ :> Sin[2. Pi pulseRate t] + 8 Sinc[Pi t 2.]^2 // # + RandomReal[0.3 {-1, 1}, Length@#] &; ListLinePlot[data, DataRange -> {0, 200}, PlotRange -> Full] Plotting Fourier already shows it will be easy to extract the ...


16

Comment This was originally answered on Oct 2, 2012 using V8. The performance can be dramatically improved using V9's URLFetchAsynchronous, as now shown below. Fortunately, we needn't download all the tiles at once. We can use Dynamic to set up a little pan-and-zoom explorer. The first load takes a bit and zooming out takes a bit. Panning and zooming ...


13

Mathematica 10 has support for a serial device which greatly simplifies things. I am capturing byte data from an XBEE on a usb card being sent from an arduino with an XBEE transmitter. In Mathematica the only commands needed to plot 200 points on a Mac are... port = "/dev/tty.usbserial-DA00X00E" dev = DeviceOpen["Serial", {port, "BaudRate" -> 9600}] ...


13

The airport utility on your mac (which is not very widely known) gives you programmatic access to all your wireless information. I wrote a fun answer on Ask Different using this command line utility. To get the information about wireless devices around you, use the -s flag. Here's a simple function to automate it: getSSID[] := With[{data = ...


11

I was finally able to connect to the serial port by using the package SerialIO created by Rob Raguet-Schofield found here http://library.wolfram.com/infocenter/Demos/5726/ and then following the instructions and testing the Arduino program that William Turkel posted in his blog. ...


11

Another way is to make use of the second argument of Dynamic. When given as a list of two functions, the first element of the second argument will be evaluated when the mouse is dragged, and the second one at the moment that the mouse is released, so in this case the the final value of the slider will be added to dataList. pt = {1, 1}; dataList = {pt}; ...


11

Alternatively, you may use LocatorAutoCreate, which adds the oportunity of adding, moving and removing points "a piaccere": DynamicModule[{pts = {{-1, 1}/2, {1, 1}/2}}, Column[{LocatorPane[Dynamic[pts], Framed@Graphics[{}], LocatorAutoCreate -> All], Dynamic@pts}]] Usage sample: i = Import@ ...


10

This is a job for EventHandler: EventHandler[ Slider2D[Dynamic[{x, y}], {{0, 0}, {5, 8}, {1, 2}}], {"MouseUp" :> AppendTo[datalist, {x, y}]}, PassEventsDown -> True ] Follow the data acquisition with a Dynamic: Dynamic[datalist] {{1,1},{3,4},{2,2},{2,4}} PassEventsDown -> True is necessary to prevent EventHandler from eating up ...


10

I wrote code for data acquisition with the Adafruit 10-DOF sensor a while back. I will share that code, with explanation, so that you can adapt it yourself. Mathematica + Adafruit == TRUE It's awesome and easy to connect to an Arduino with Mathematica: Open a connection to Arduino and specify the paths to the Adafruit libraries (I put the library folders ...


10

Here's something to get you started down to path of scraping the somewhat larger individual pictures from the Nobel website: links = Import[ "https://www.nobelprize.org/nobel_prizes/physics/laureates/index.html?images=yes", "Hyperlinks"]; individualpagelinks = Select[ links, StringMatchQ[ ...


9

If this device support NI-VISA (as I understood from your reference to LabVIEW), then you can use following way: Install the VISA engine (available at National Instruments' web-site) Use the following code. Needs["NETLink`"] lib = LoadCOMTypeLibrary[ "C:\\Program Files (x86)\\IVI \Foundation\\VISA\\VisaCom\\GlobMgr.dll"] mgr = ...


8

I recently discovered SocketLink bundled with Mathematica. It's not documented, but super straightforward: << "SocketLink`" port = 1234; s = CreateClientSocket["host", port] {inputStream, outputStream} = OpenSocketStreams[s]; This returns a binary InputStream and OutputStream that you can read/write like any other Mathematica stream with BinaryRead ...


8

Here is my sample code using JLink. It's not a foolproof code, but if someone know haw to do better, please let me know. The following code let Mathematica connect with T3Open Trading Software (Italian Broker WeBank), it expose some api that you can call with tcp socket. In this example I'm going to pass a list of options code (Terna Call) and take the ...


8

Calling Wolfram|Alpha is not generally an efficient way to retrieve bulk data; where possible, it is better to use a built in data function. Part of the problem is figuring out what to submit to Wolfram|Alpha. In the code you supplied, the issue begins with Wolfram|Alpha returning Missing[NotAvailable]. WolframAlpha["AAPL ...


7

Join[ Table[Quantity["5 feet 11 inches"], {7}], Table[Quantity["5 feet 10 inches"], {20}] ] So there are three things going on here -- we are using Mathematica Version 9 Quantity for things with units, Table to make individual lists of a given length, and Join to concatenate them. You could also use ConstantArray instead of Table, and various ...


7

This appears to be working: Do[tab = RandomReal[{0, 1}, 10]; PutAppend[tab, "test123.csv"], {5}] ReadList["test123.csv", Expression] You may also wish to look at WriteString which will allow for complete control of what is written. In a comment Ajasja makes an excellent point regarding performance. If your application is anything like the dummy ...


6

Since Mathematica 10 it's possible to pull data from Google Analytics using ServiceConnect and ServiceExecute. I refer you to the documentation for all the details, but here is a small sample. Establish a connection: ga = ServiceConnect["GoogleAnalytics"] Get the number of visitors and the number of sessions over the last ten days: req1 = ...


6

I just logged into Google Analytics and had a look at the export formats they offer. They offer many different formats that can be read by Mathematica: CSV, TSV and Excel are those that stand out as very easy to work with. Here is an example where I chart the number of visitors over a certain period of time: data = ImportString["Day Index,Visits ...


6

Yes, it is possible to use the ellipsoidal Mercator projection by specifying an ellipsoidal "ReferenceModel" in the projection. To compare, let me define a spherical Mercator projection: In[1]:= webMercator = {"Mercator", "ReferenceModel" -> GeodesyData["ITRF00", "SemimajorAxis"]} Out[1]= {"Mercator", "ReferenceModel" -> Quantity[6.37814*10^6, ...


6

First I got the same error message. Using the menu bar Edit ► Preferences... and clicking the "Update Local Indices from Wolfram Research Server" button under the Internet Connectivity tab fixed this erroneous behavior.


6

img = ImageTrim[ Import["http://i.stack.imgur.com/MBL2d.png"] , {{30, 4}, {1910, 287}} ] Total[ImageData@ ColorNegate@ Binarize[ ColorSeparate[img][[3]]], 2] 142017 That is the number of pixels in the plot for download data. Vertical axis is 2.99404 KB/s/pixel. Horizontal axis is 1.27524 secs/pixel Total download 142017 ...


6

I wrote this in the comment, but the code did not come out properly formatted. So here it is again: Import["https://en.wikipedia.org/wiki/Mathematica", "Images"]


6

If the problem is only to remove the grid, that's relatively easy. You just remove everything but the grid, then take the difference. You can use Closing with a rectangular structuring element to remove everything but the horizontal / vertical grid lines, like this: img = Import["http://i.stack.imgur.com/TkvSR.png"]; hFilter = Closing[img, ...


5

You're looking for Skip. This does not check for an EndOfFile condition, and should use something like BlockStream to handle aborts, but the following should work: strm = OpenRead["filename"]; (* Repeat the following until done *) Skip[strm, String, A]; AppendTo[ results, Read[strm, String]] (* String just gets the entire line. If the number of ...


5

As suggested by @J.M. you don't need WolframAlpha. One way is to define : temperatureComparison[{city1_, city2_}, {date1_, date2_}] := Module[{data1, data2, int1, int2}, data1 = {AbsoluteTime[#[[1]]], #[[2]]} & /@ WeatherData[city1, "MeanTemperature", {date1, date2, "Day"}] ; data2 = {AbsoluteTime[#[[1]]], #[[2]]} & /@ WeatherData[city2, ...


5

There's no easy way, it's a custom script that assembles the image out of individual slices, and it's written by someone who clearly didn't intend anyone to read it again (including himself). Reverse engineering. The script responsible is http://imgs.xkcd.com/clickdrag/1110.js, the image to be displayed is assembled in line 86 ($image=...). Scanning the ...



Only top voted, non community-wiki answers of a minimum length are eligible