wolfram-mathematica

Efficient way to pick/delete a list of rows/columns in a matrix in Mathematica

半城伤御伤魂 提交于 2019-12-18 04:21:03
问题 This question is in a way a continuation of the question I asked here:Simple way to delete a matrix column in Mathematica to which @belisarius and @Daniel provided very helpful answers. What I am generally trying to do is to extract from a matrix A specific lines and columns OR what remains after what those specified are removed. So this can be formally writtewn as, find TakeOperator and Drop Operator such that: TakeOperator[A,{i1,..,ip},{j1,...,jq}]=(A[[ik]][[jl]]) (1<=k<=p, 1<=l<=q) = Table

How do I get auto-conversion of Part [[ double-brackets ]] on paste?

倾然丶 夕夏残阳落幕 提交于 2019-12-18 03:38:44
问题 A pet peeve of mine is the use of double square brackets for Part rather than the single character \[LeftDoubleBracket] and \[RightDoubleBracket] . I would like to have these automatically replaced when pasting plain-text code (from StackOverflow for example) into a Mathematica Notebook. I have been unable to configure this. Can it be done with ImportAutoReplacements or another automatic method (preferred), or will I need use a method like the "Paste Tabular Data Palette" referenced here?

Why do I have to evaluate this twice?

◇◆丶佛笑我妖孽 提交于 2019-12-17 23:17:56
问题 I cannot figure out why I have to evaluate this twice (in Mathematica 7) for the assignment to take. First evaluation: Unprotect[Rule]; Attributes[Rule] pp = Plot | LogLinearPlot | ListPlot | ParametricPlot3D; (h : pp)[True -> False] ^:= Print["Irrelevant data"] (* Out[2]= {SequenceHold} During evaluation of In[1]:= UpSetDelayed::write: Tag Rule in (h:Plot|LogLinearPlot|ListPlot|ParametricPlot3D)[True->False] is Protected. >> Out[4]= $Failed *) As can be seen from Out[2]= {SequenceHold} ,

Mathematica: 3D wire frames

淺唱寂寞╮ 提交于 2019-12-17 19:43:08
问题 Does Mathematica support hidden line removal for wire frame images? If this isn't the case, has anybody here ever come across a way to do it? Lets start with this: Plot3D[Sin[x+y^2], {x, -3, 3}, {y, -2, 2}, Boxed -> False] To create a wire frame we can do: Plot3D[Sin[x+y^2], {x, -3, 3}, {y, -2, 2}, Boxed -> False, PlotStyle -> None] One thing we can do to achieve the effect is to color the all the surfaces white. This however, is undesirable. The reason is because if we export this hidden

How to dynamically generate mathematica code?

a 夏天 提交于 2019-12-17 18:56:24
问题 I want to make a mini programming language in mma. From a textfile to Module(s) in a Package. Ideally I should be able to generate the package and modules from within Mathematica by functions in another package. Question: Is this possible? I am looking for a reference or an example to get this started. EDIT: For example: Imagine a memory bank with n integer typed registers. The instructions are: 1 Z(n) 2 C(m,n) 3 J(m,n,q) 4 S(n) Each line has an address. First line 1, second 2, etc. Z(n)

Defining a function with an optional value that is by default a function of another paramether of the function in mathematica

北城以北 提交于 2019-12-17 18:44:14
问题 I am trying to define a function that takes in a Matrix and when its dimensions are not provided as input, compute these dimensions in the optional parameter d This does not work but gives you the idea (The options parameter need be constants): Options[DimM] = {d -> Dimensions[A]}; DimM[A_?MatrixQ, OptionsPattern[]] := OptionValue@d; Indeed the simple way is to input an impossible value and in the function def put an if condition as in Options[DimM] = {d -> 0}; DimM[A_?MatrixQ, OptionsPattern

Upload to ifile.it through Mathematica

谁都会走 提交于 2019-12-17 15:47:13
问题 I was wondering whether it's possible to upload a file from Mathematica to ifile.it. I have seen the API of ifile.it, however, I still don't know how it works. Furthermore, the closest example I've seen in Mathematica is 'Twittering with Mathematica', but it's not clear to me, how can I use a GET request from that example. Thanks in advance 回答1: Setup the Java HttpClient library. << JLink` client = JavaNew["org.apache.commons.httpclient.HttpClient"] (* Out[3]= JLink`Objects`vm1

Delete repeating list elements preserving order of appearance

笑着哭i 提交于 2019-12-17 11:00:58
问题 I am producing flat lists with 10^6 to 10^7 Real numbers, and some of them are repeating. I need to delete the repeating instances, keeping the first occurrence only, and without modifying the list order. The key here is efficiency, as I have a lot of lists to process. Example (fake): Input: {.8, .3 , .8, .5, .3, .6} Desired Output {.8, .3, .5, .6} Aside note Deleting repeating elements with Union (without preserving order) gives in my poor man's laptop: DiscretePlot[a = RandomReal[10, i];

Matching brackets in a string

倖福魔咒の 提交于 2019-12-17 10:52:03
问题 What is the most efficient or elegant method for matching brackets in a string such as: "f @ g[h[[i[[j[2], k[[1, m[[1, n[2]]]]]]]]]] // z" for the purpose of identifying and replacing [[ Part ]] brackets with the single character forms? I want to get: With everything else intact, such as the prefix @ and postfix // forms intact An explanation of Mathematica syntax for those unfamiliar: Functions use single square brackets for arguments: func[1, 2, 3] Part indexing is done with double square

Import big files/arrays with mathematica

断了今生、忘了曾经 提交于 2019-12-17 10:15:44
问题 I work with mathematica 8.0.1.0 on a Windows7 32bit platform. I try to import data with Import[file,”Table”] which works fine as long as the file (the array in the file) is small enough. But for bigger files(38MB)/array(9429 times 2052) I get the message: No more memory available. Mathematica kernel has shut down. Try quitting other applications and then retry. On my Windows7 64bit platform with more main memory I can import bigger files, but I think that I will have there the same problem