wolfram-mathematica

Behavior of Part inside Function

泄露秘密 提交于 2020-01-06 15:22:06
问题 The following gives some strange "Part" warnings Clear[f]; f = Function[{x}, x[[1]] == x[[2]]] However if I execute the second line again, it works without warnings, any idea what's going on? 回答1: Are you sure? I don't see any warnings in version 7.0.1: In[1]:= Clear[f]; f=Function[{x},x[[1]]==x[[2]]] Out[2]= Function[{x},x[[1]]==x[[2]]] 来源: https://stackoverflow.com/questions/4093657/behavior-of-part-inside-function

Customize ANOVA table in Mathematica

孤者浪人 提交于 2020-01-06 10:58:26
问题 Is there a way to customize the way ANOVA table look ? Without to much effort manipulating each element of the list ? 回答1: You could try Grid[(ANOVA /. yourresult)] and the various styling options for Grids described in the documentation. (see also the tutorial) If there is a hidden TableForm on the right hand side of that rule, you might need to do something like Grid[InputForm[(ANOVA /. yourresult)]] . 来源: https://stackoverflow.com/questions/7425696/customize-anova-table-in-mathematica

Customize ANOVA table in Mathematica

时光毁灭记忆、已成空白 提交于 2020-01-06 10:58:26
问题 Is there a way to customize the way ANOVA table look ? Without to much effort manipulating each element of the list ? 回答1: You could try Grid[(ANOVA /. yourresult)] and the various styling options for Grids described in the documentation. (see also the tutorial) If there is a hidden TableForm on the right hand side of that rule, you might need to do something like Grid[InputForm[(ANOVA /. yourresult)]] . 来源: https://stackoverflow.com/questions/7425696/customize-anova-table-in-mathematica

How to draw line 'y=x' using PolarPlot in mathematica?

夙愿已清 提交于 2020-01-05 07:44:29
问题 Because PolarPlot should type r=... type of command. But y=x will cause r to disappear. How to draw that line with PolarPlot ? 回答1: I suggest you use a new function for things like this. PolarParametricPlot[ {rT : {_, _} ..} | rT : {_, _}, uv : {_, _, _} .., opts : OptionsPattern[] ] := ParametricPlot[ Evaluate[# {Cos@#2, Sin@#2} & @@@ {rT}], uv, opts ] Usage: PolarParametricPlot[{t, 45 Degree}, {t, -10, 10}] 回答2: First, consider Plot[] which "generates a plot of f as a function of x from

What does a matrix array look like for a Johnson graph?

强颜欢笑 提交于 2020-01-05 05:10:01
问题 I can't seem to find any examples (or much information at all) of what a matrix array looks like for a Johnson graph. Can anyone send me an example of what their arrays look like? 回答1: This directly uses the definition of a Johnson Graph given here Wiki Johnson Graph johnsonmatrix[n_, k_] := Module[{s=Select[Subsets[Range[n]], Length[#]==k&]}, {s, MatrixForm[Table[If[Length[Intersection[s[[i]], s[[j]]]]==k-1, 1, 0], {i, Length[s]}, {j, Length[s]}]]}] and generates the list of subsets which

classification tree implementation in mathematica

社会主义新天地 提交于 2020-01-04 14:28:52
问题 I want to implement simple classification tree (binary classification) using Mathematica. How can I implement a binary tree in Mathematica ? Is there is a symbol for doing that? 回答1: I'd say it depends on what you want to do with the data structure. You can exploit the fact that Mathematica expressions themselves are trees. If only the leaf nodes are relevant, then use nested lists, e.g. {{1, {2, 3}}, 4} . If the other node need to carry some data too, then you can use something like this:

manipulate list in mathematica with select

有些话、适合烂在心里 提交于 2020-01-04 04:13:26
问题 I have imported some data into Mathematica. The data will look similar to {{0,2},{2,3},{4,3},{5,4},{8,4}} I want to throw out all elements for which the x-values are smaller than a given value or create a new list that contains the data for which the x-values are larger than this value. I assume that Select should do the job but I don't know how. Thanks in advance for the help. 回答1: How about data = {{0,2},{2,3},{4,3},{5,4},{8,4}}; filtered = Select[data, First[#]>3&]; where you replace 3

How can I define a abstract odd function in mathematica?

你说的曾经没有我的故事 提交于 2020-01-04 01:52:32
问题 How can I define a abstract odd function, say f[x]. Whenever f[x]+f[-x] appears, mathematica simplifies it to zero. 回答1: This can be done easily using upvalues f[x_] + f[y_] /; x == -y ^:= 0 Normally Mathematica would try to assign the above rule to Plus , which of course does not work since that's protected. By using ^:= instead of := you can assign the rule to f . A quick check yields: In[2]:= f[3]+f[-3] Out[2]:= 0 Edit: This, however, only works for Plus . It's probably better to use

After submitting a .m batch job with Slurm, can I edit my .m file without changing my original submission?

三世轮回 提交于 2020-01-04 01:11:06
问题 Say I want to run a job on the cluster: job1.m Slurm handles the batch jobs and I'm loading Mathematica to save the output file job1.csv I submit job1.m and it is sitting in the queue. Now, I edit job1.m to have different variables and parameters, and tell it to save data to job1_edited.csv. Then I re-submit job1.m. Now I have two batch jobs in the queue. What will happen to my output files? Will job1.csv be data from the original job1.m file? And will job1_edited.csv be data from the edited

Mathematica “AppendTo” function problem

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-03 17:01:01
问题 I'm a newbie in Mathematica and I'm having a major malfunction with adding columns to a data table. I'm running Mathematica 7 in Vista. I have spent a lot of time RFD before asking here. I have a data table (mydata) with three columns and five rows. I'm trying to add two lists of five elements to the table (effectively adding two columns to the data table). This works perfectly : Table[AppendTo[mydata[[i]],myfirstlist[[i]]],{i,4}] Printing out the table with: mydata // TableForm shows the