Hot answers tagged

9

One can also use Import[] to directly query the *.wav file's sample rate, like so: Import["ExampleData/rule30.wav", "SampleRate"] 44100


8

solo = Import[ "ExampleData/rule30.wav" ] Cases[solo, (SampledSoundFunction | SampledSoundList)[__, r_] :> r, Infinity][[1]] 44100


6

The sample rate is the second element in solo. The first element (i.e., solo[[1, 1]]) is the waveform data. solo = Import["ExampleData/rule30.wav"]; solo[[1, 2]] 44100


5

If you don't want to save the file to the disk, you can use stream to do the trick. You can import the zip file as a string from the web and convert it to stream, which then can be treated as a file. For example: url="http://www.retrosheet.org/gamelogs/gl2015.zip"; str=Import[url, "String"]; filename = First@Import[StringToStream[str], "ZIP"]; ...


5

The syntax you use is wrong. There is no import element called "P" for the MAT format. Take a look at the documentation: it lists the allowed elements: "Elements", "Rules", "Options", "Data", "LabeledData", "Comments", "Labels". You probably want "LabeledData", so use Import["file.mat", {"MAT", "LabeledData"}] or alternatively Import["file.mat", ...


4

columnames=CharacterRange["a","h"]; data= RandomInteger[9,{20,8}]; ds=Dataset[AssociationThread[columnames->#]&/@data]


3

Okay, so this is what it looks like with standard coloring of the residues: Import["ExampleData/1PPT.pdb", ColorFunction -> "Residue"] But now, if we want to change the residue colors, we need to change the value of a certain internal color list called Graphics`MoleculePlotDump`residueColorRules residuelist = {"Gly", "Pro", "Ser", "Gln", "Pro", ...


3

You can export as a MATLAB .mat file if your array has less than 4 dimensions, rand = RandomReal[1, {1000, 3, 3}]; Dimensions@rand rand[[454, 1, 2]] Export["random.mat", rand]; (* {1000, 3, 3} *) (* 0.786307 *) When you import it again, you have the same dimensions and the elements are the same rand2 = Import["random.mat"]; Dimensions@rand2 rand2[[454, ...


3

After experimenting with the free multiplatform tool GPSBabel (http://www.gpsbabel.org/) and with the Python module Fitparse (https://github.com/dtcooper/python-fitparse), I can share the following: If you want latitude and longitude only, GPSBabel is fine. It converts the spatial coordinates in a Fit file into GPX format, which Mathematica can import. ...


2

This turned out to be pretty simple, using ClickPane to capture the clicks, and MousePosition so that you can see the current coordinates. After running the code below, and placing your mouse over the plot, the coordinates are displayed above the plot. After clicking, the coordinates you click are added to the list pts. This bypasses any interaction with ...


2

The WriteString in your loop form should be: WriteString[path, 0.01*i, " ", 1/((y[30]^2 + y[30 - Pi/2]^2)) /. First@s, "\n"] This gives you no { } in the file and Imports properly. You could also use Write: Write[path, 0.01*i, OutputForm[" "], 1/((y[30]^2 + y[30 - Pi/2]^2)) /. First@s] That said its usually preferable to generate ...


1

OK, I found a second way. Like kglr's solution, this one also uses AssociationThread, but applies it only once: makeDataset[columns_, columnLabels_] := Module[{labeledColumns, records}, labeledColumns = AssociationThread[columnLabels, columns]; records = Transpose[labeledColumns, AllowedHeads -> All]; Dataset[records] ]; The importer can be ...


1

You need Import, Part (i.e. [[...]]), probably Span (i.e. ;;), and Total. Import the data: data = Import["path\to\yourdatafile.txt", "Table"]; Sum all entries in the first column: Total@data[[All, 1]] Sum entries in the third column and in the second to third row: Total@data[[2 ;; 3, 3]] Sum entries in column 2, rows 1 and 3: Total@data[[{1, 3}, ...


1

You might try to use Locatorfor this purpose. Try this: coord = {}; DynamicModule[{pt = ImageDimensions[im]/2 // N}, Column[{ Show[{ image, Graphics[Locator[Dynamic[pt]]] }], Dynamic[pt], Button["Get coordinates", Clear[coord]; coord = pt] }] ] where ┬┤image` is the name of your image and coord is the global variable. You ...



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