wolfram-mathematica

Creating a variable length string of whitespaces in Mathematica

旧街凉风 提交于 2019-12-23 09:57:47
问题 The following Mathematica function f creates a string of whitespace of length n. f[n_]:=Fold[StringJoin,"",Array[" "&,n]] There must be a zillion alternatives to create this function. How would you have done it? 回答1: f[n_] := StringJoin @ ConstantArray[" ", n] Edit: since @ is as idiomatic as @@ and a bit faster (thanks to Mr.Wizard for benchmarking) and shorter i updated the solution. 回答2: f[n_] := FromCharacterCode[ConstantArray[32, {n}]] By the way: you should be aware that this type of

Command-line arguments of Mathematica Kernel and FrontEnd

风流意气都作罢 提交于 2019-12-23 09:47:22
问题 I still know nothing on usage of such command-line options of MathKernel as -lmverbose -run cmd -password "pw" -pwfile "file" How are they working and what they are needed for? Are there other potentially useful command-line options of the MathKernel and the FrontEnd? P.S. Related answer. 回答1: Please consult the following reference pages: MathKernel and Mathematica. Opening "More Information" section you will see documented options. Its says -pwfile "file" ------- read passwords from file

Gradient Fill using Graphics in Mathematica

扶醉桌前 提交于 2019-12-23 09:38:44
问题 How could I create the following using Rectangle[] in Graphics[] ? 回答1: Using Polygon , you can Graphics[{EdgeForm[Black], Polygon[{{0, 0}, {3, 0}, {3, 1}, {0, 1}}, VertexColors -> {White, Red, Red, White}]}] 回答2: Also: Graphics[Raster[{Range[100]/100}, ColorFunction -> (Blend[{White, Red}, #] &)], AspectRatio -> .3, Frame -> True, FrameTicks -> None] 来源: https://stackoverflow.com/questions/8142179/gradient-fill-using-graphics-in-mathematica

PlotLegends makes Manipulate[] ing graphs slow to a crawl

时间秒杀一切 提交于 2019-12-23 09:26:22
问题 I have a short program set up to display three plots of the same function with different parameters using Manipulate. I'd like to label each function with the value of the parameter. My starting point was to just get a legend to show up at all. Adding a PlotLegend to the plot causes Mathematica to become unusably slow. My code is: Needs["PlotLegends`"] Manipulate[ UemaxOverUe = ((VA/Vphs)^2 (2 p - 1) + 1 - Ves0/Vphs - 2)/((VA/Vphs)^2 - (1 - Ves0/Vphs)); UemaxOverUe2 = ((VA/Vphs)^2 (2 p - 1) +

How can I programmatically access information about a 'Graph` object in Mathematica 8?

半腔热情 提交于 2019-12-23 08:58:02
问题 I'm trying to access information within a Graph object in Mathematica 8. For some reason, the Part command does not seem to work. myGraph is the object I want to gain access to. The first line below displays myGraph. The others serve to inspect it. myGraph myGraph // FullForm myGraph // InputForm myGraph // OutputForm myGraph[[1]] myGraph[[2]] Why doesn't myGraph[[1]] return List[1,3,4,2,5] ? [I checked to level 2 just in case Graph were wrapped by some invisible wrapper. Level[myGraph,1] ,

Any performance issues with defining modules as part of Manipulate expression vs. in the initialization section?

主宰稳场 提交于 2019-12-23 08:52:48
问题 I'd like to ask if any one knows of any issues (performance or otherwise) if one were to define/put the module(s) used by the Manipulate expression, right inside the Manipulate expression itself, vs. in the initialization section, where normally it is done. Both methods work, but the semantics are not the same when it comes to direct access to Manipulate dynamics from the module (vs. them being passed as arguments to the module, which is the better method actually, but I am trying something

Any performance issues with defining modules as part of Manipulate expression vs. in the initialization section?

淺唱寂寞╮ 提交于 2019-12-23 08:52:12
问题 I'd like to ask if any one knows of any issues (performance or otherwise) if one were to define/put the module(s) used by the Manipulate expression, right inside the Manipulate expression itself, vs. in the initialization section, where normally it is done. Both methods work, but the semantics are not the same when it comes to direct access to Manipulate dynamics from the module (vs. them being passed as arguments to the module, which is the better method actually, but I am trying something

Data from Mathematica import to Python

浪子不回头ぞ 提交于 2019-12-23 04:47:09
问题 I have a text file containing 3 dimensional array(100X100X100) obtained from Mathematica. The data are stored with commas and curly braces.I want to use this text file to analyse and plot the data using Python. How can I import the data in Python? I am currently using Python 2.7 version. What may be the format to store the data in matematica in order to use it in Python? 回答1: since it pains me to see folks storing so much data in ascii, here is a way to do a binary exchange: mathematica: data

Why does FindMaximum with Newton's method complain it can't find a sufficient decrease in function?

主宰稳场 提交于 2019-12-23 03:55:08
问题 Firstly, this seems like (from ContourPlot) a fairly straightforward maximization problem, why is FindMaximum with Newton's method having problems? Secondly, how can I get rid of the warnings? Thirdly, if I can't get rid of these warnings, how can I tell if the warning is meaningful, ie, maximization failed? For instance, in the code below, FindMaximum with Newton's method gives a warning, whereas the PrincipalAxis method doesn't o = 1/5 Log[E^(-(h/Sqrt[3]))/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt

How to specify arbitrarily the thickness of lines or size of points in mathematica

我的梦境 提交于 2019-12-22 17:06:25
问题 I know there are options such as PointSize[Large] or PlotStyle -> Thick , but what if I want to even larger or thicker? Thank you. 回答1: PointSize[number] -- size relative to the image AbsolutePointSize[number] -- absolute size in points Thickness[number] -- thickness relative to the image AbsoluteThickness[number] -- absolute thickness in points Basically the size given by PointSize[0.1] and Thickness[0.1] scale as you resize the graphic. AbsolutePointSize[10] and AbsoluteThickness[10] are