Tag Info

Hot answers tagged

23

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 ...


20

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 ...


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 ...


14

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 ...


12

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. ...


10

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}; ...


10

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@ ...


9

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 ...


9

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}] ...


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 ...


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

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

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 ...


5

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 ...


5

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 NI web-site) Use following code. Needs["NETLink`"] lib = LoadCOMTypeLibrary[ "C:\\Program Files (x86)\\IVI \Foundation\\VISA\\VisaCom\\GlobMgr.dll"] mgr = NETNew["Ivi.Visa.Interop.ResourceManagerClass"]; ...


4

WeatherData[] can give you what you want: startdate = DateList[]; city = "Amsterdam" startpoint = 5 (*hours ago: for amsterdam, the most recent data was not available...*) range = 48 (*in hours*) data = WeatherData[city,"Temperature", #] & /@ (DatePlus[DateList[], {-#, "Hour"}][[1 ;; 4]] & /@ Range[startpoint, range]); For some reason WeatherData ...


4

You can download all the original tiles using the following functions. 404 and file not founds are handled gracefully. I'm avoiding displaying to the FE so as to lower the chances of crashing. url[n1_Integer, d1_String, n2_Integer, d2_String] := "http://imgs.xkcd.com/clickdrag/" <> ToString@n1 <> d1 <> ToString@n2 <> d2 <> ...


4

If you're downloading a website it may not be entirely static. So you need to download the file and check the headers at the same time, you cannot do it separately. Therefore URLSave is easier to use, even though URLFetch can also to be used. Like Joel Klein says there isn't a checksum by default for every page. However, we could use the header ...


4

After grabbing the data from WeatherData, use Cases to get only those datapoints obtained on the 15th day: data = WeatherData["Helsinki", "MeanTemperature", {{2011, 1, 1}, {2012, 12, 31}, "Day"}]; just15 = Cases[data, x_ /; x[[1, 3]] == 15];


4

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 ...


4

If you have a notebook with the following assignment: g = Graph[{1 \[DirectedEdge] 2, 2 \[DirectedEdge] 3, 3 \[DirectedEdge] 1}, EdgeShapeFunction -> "CarvedArcArrow"] And the output is visible (note that Head[g] is Graph not Graphics and then you kill the kernel so that g is no longer assigned, you can retrieve the original graph by doing the ...


3

It is possible to access data via Import even in a (nonenterprise) .cdf. It must be a publicly available website (i.e., no login or passwords), and there may be other restrictions. In any case, here is code some that does the import: imageNames = {"http://www.massmurdermedia.tv/images/TV%20Test%20Pattern%2007.jpg", ...


3

I have no idea why DateListPlot does not work with Quantity. Perhaps it's a bug? But the workaround is very easy: using pattern replacements we extract the numerical values. DateListPlot[nominal /. Quantity[x_, _] :> x, FrameLabel -> {"year", "$ per year"}] Browsing through the help, another option is QuantityMagnitude. ...


3

mergeV[g_, v1_, v2_] := Graph[#[[1]], EdgeWeight -> #[[2]], EdgeLabels -> "EdgeWeight", VertexLabels -> Placed["Name", Center], VertexSize -> 0.3] &@ Transpose[ Transpose[{EdgeList[g], PropertyValue[g, EdgeWeight]}] /. {v1-> new, v2 -> new} /. {new \[DirectedEdge] new, x_} -> Sequence[] //. {a___, {new ...


3

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 ...


3

Data import and export are not supported from within CDF Player with the exception of Wolfram-curated data sources (ChemicalData, CountryData, WordData, etc.). Because CDF Player cannot load custom data at runtime, you must ensure that all necessary information is embedded within the interactive elements of your .cdf file. This can be done with ...


3

According to the comments you have several options: Use Import and Export to work with Excel files (noted: this is not straightforward with problems mentioned in the comments). Use this answer to manipulate the Excel file like it is done in VB. Using Leonid's SQL DSL as a way to get database like syntax while keeping all the data in Mathematica lists. I ...


3

To simulate the situation, evaluate the following expression and then quit the kernel: $graph = RandomGraph[{50, 50}] We can verify that $graph no longer holds the graph by observing its syntax coloring, or by evaluating it. To recover the graph, enter and evaluate the following expression in a new input cell directly below the output cell that holds ...



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