# Tag Info

13

Yes, there is! Mathematica creates a LibraryFunction when compiling to C, but puts it in a temporary directory. If you can recover the library, you can load it as often as you like! First let's define the function as in the question: generatef[opt_] := Compile[{}, Module[{j = 0}, Do[j++, {i, 10^8}]; j], CompilationTarget -> opt]; f2 = generatef["C"]; ...

11

One very clean way to do this is via x3dom, which is a javascript framework for deploying the x3d standard. The library is well supported by modern browsers, and the output is an html file with a supporting archive of x3d files. It is generally very clean and fast, and it does not require any external plugins. The library can be called from the x3dom site or ...

10

The way I typically handle this type of situation is to export the individual images, then have software like FFmpeg handle the conversion to video. FFmpeg in particular is an extremely powerful tool (and is available for Windows, OS X, and most Linux distros). First download the appropriate binary for your system. I placed the ffmpeg binary in the ...

7

Using either Swatchlegend, PointLegend, LineLegend, Barlegend you can easily generate a legend like you would get in a plot. SwatchLegend[{Red, Green, Blue}, {"red", "green", "blue"}] PointLegend[{Red, Green, Blue}, {"red", "green", "blue"}] LineLegend[{Red, Green, Blue}, {"red", "green", "blue"}] BarLegend["Rainbow"] Non-default styles are ...

6

Update: Generate a separate legend with the default color scheme and export it: lineleg = LineLegend["DefaultPlotStyle"/. (Method/. ChartingResolvePlotTheme[Automatic, ListLinePlot]), {"leg1", "leg2", "leg3"}]; Export["plotlegend.pdf",lineleg] To get the default colors associated with various PlotThemes you can use the function ...

5

After a bit of consideration I recommend that you use ParallelSubmit and related functionality, e.g. WaitAll. Please consider this example: job = Array[ParallelSubmit[Pause[1]; If[Random[] > 0.7, Quit[]]; Print[#]] &, 10] This creates a series EvaluationObject tasks to perform. Within each is a 30% chance of failure simulated by If[Random[] ...

4

Figured it out. For some unknown reason, GridLines created with DateRange and Quantity magically export in .eps. GridLines -> {DateRange["2016", "2019", Quantity[3, "Months"]], None} I have no idea why this form works while Automatic does not.

4

You can generate a random signal, if that is indeed what you mean, using a random walk. For example, 1000 samples would look something like this: (* Generate the samples and plot *) samples = Accumulate[RandomReal[{-1, 1}, 1000]]; ListLinePlot[samples] (* And to export them to CSV *) Export["\\path\\to\\file\\randomsamples.csv", samples, "CSV"]; And ...

4

You need to ask yourself a few more questions about what you want. If you want your random numbers to be uniformly distributed in the $(a,b)$ interval, the easiest functions to use are RandomReal to get real numbers, or RandomInteger to get integer values. These functions are similar to the RAND() function in Excel or similar spreadsheets. RandomVariate is ...

3

Update 2015-05-14 I contacted WRI support and they confirmed that this is a known issue with Export (support case: 3206586). Summary @ChenStatsYu seems to have found an unexplained behavior of the Export function for PDF files that looks like a bug. Detailed results 1) I generated two graphics similar to those in the OP's original question, then ...

2

Use Export["data1.mat", WW1] Export["data2.mat", WW2] Is that what you want? Or combined them into a single matrix using Mathematica, then export the whole matrix. But without the double quotes.

2

I appreciate the solution given by Jens and find it's a nice one. The problem with that solution is that the required font Times-Roman is actually missing from the Type1 Mathematica folder. So I just wanted to share a workaround I found. It's very simple. Open your pdf in Adobe Illustrator, hit OK when proposed to use a substitute font. Go to the ...

2

UPDATE: an export routine written from scratch After clarifications from Zoe, I realize that her problem is not in the export format; not even in the sneaky way that Mathematica tries to outsmart the user by performing hidden unit conversions. The problem is the output number format! I couldn't find a way to convince the Export function to output numbers ...

1

Windows users can use my MathMF package for this. There's no need to export the frames as images, you just write them directly to a video stream as you create them. It doesn't have the flexibility of third party tools like ffmpeg but it's good for a quick and easy video export without storing all frames in memory. Example code: Needs["MathMF"] {w, h} = ...

1

Update: I haven't written any C in a long while, so I forgot its syntax for multidimensional arrays, i.e. array[first][second]! Here is the amended code: ToString[CForm[t[12, 156] + ht u[5, 3]]] StringReplace[%, { "t(" ~~ Shortest[a__] ~~ "," ~~ Shortest[b__] ~~ ")" -> "t[" ~~ a ~~ "][" ~~ b ~~ "]", "u(" ~~ Shortest[a__] ~~ "," ~~ Shortest[b__] ~~ ...

1

This is unfortunately not an answer, but an extended comment that outgrew the comment form. In short, this might be a bug in ExportString. I am using Mathematica v. 10.1.0 on Windows 7 - 64 bit. Here's what I tried so far. I tried to export your JSON content to a file, using the same format you proposed. This works just fine. Export["fromExport.json", ...

1

(Updated for clarity) Skimming through Developing an Export Filter is helpful in understanding the process I describe below. First, it is helpful to see what Mathematica is doing when it exports an XYZ file. To figure this out, we can look at the appropriate formatting package: FileNameJoin[{\$InstallationDirectory, "SystemFiles", "Formats", "XYZ", ...

1

This seems to work: list = Style @@@ ColorData["Crayola", "ColorRules"]; Export["test.rtf", Cell[BoxData @ ToBoxes @ #, "Output"] & /@ list]

1

The challenge for me was concatenating styled strings. To concatenated the styled text for output, just put a space between them. With that the styles export successfully: Export["test.rtf", Style["Arff", Red] Style["Meow", Blue] ] That made the text is colored correctly when opened with Word on Windows. You can also try: ...

1

Personally, in this case I think Do is acceptable. However, an arguably more elegant way of approaching the task, where you don't need to specify the number of elements in plottable, is with MapIndexed. MapIndexed[Export["Plot" <> ToString @@ #2 <> ".pdf", #1, "PDF"] &, plottable] Unlike Do this returns a list of the outputs of Export, ...

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