wolfram-mathematica

Making plots that also show up points/dots for specific coordinates

北城余情 提交于 2019-12-11 17:26:37
问题 I am trying to do a plot in Mathematica of something like x^2 + y^2 with x, y € [-10, 10]. Besides showing the plot, I'd also like it to include points (for example, (0, 0)) painted in a different color. Point (0,0) would be shown as (0, 0, 0). Point (1, 1) would be shown as (1, 1, 2), etc. Here is what I am looking for: How can I achieve this? 回答1: f[x_, y_] := x^2 + y^2; t = Flatten[Table[{x, y, f[x, y]}, {x, 0, 10, 1}, {y, 1, 2, 1}], 1]; a = ListPointPlot3D[t, PlotStyle -> PointSize[0.05]]

Multivariate Functions with Conditions in Mathematica

雨燕双飞 提交于 2019-12-11 16:52:19
问题 I'm trying to define a bivariate function that takes values depending on whether a condition is met. I make them work for univariate case but I'm stuck with the bivariate case: g[x_, y_] := 10 /; x < 10 g[x_, y_] := 20 /; (x >= 10 && y < 5) g[x_, y_] := -5 /; (x >= 10 && y >= 5); This function never gives me the value of -5. g[12,10] = 20? 回答1: This works for me: Clear[g] g[x_, y_] /; x < 10 := 10 g[x_, y_] /; x >= 10 \[And] y < 5 := 20 g[x_, y_] /; x >= 10 \[And] y >= 5 := -5 then In[73]:= g

Plot using one column from a table as the x-value, other columns as y-values

…衆ロ難τιáo~ 提交于 2019-12-11 10:46:17
问题 I have a matrix, the first column being the time, and the second column being the position of A, the third column the position of B, etc. I would like to plot the positions of A, B, ..., as functions of the time, in the same figure. Is there a more efficient way in Mathematica than making the plots column by column and then combining them by "Show"? Also, I would like the plots have their colors automatically chosen to differ from each other; to let this automation useful, a legend is

Why Message is not always traced?

喜你入骨 提交于 2019-12-11 10:19:47
问题 I am still puzzled by the fact that Message is not always traced when switching On[Message] while surely this function is called through the evaluator. Consider: In[1]:= On[Message,Plus]; 1+1 Sin[1,1] During evaluation of In[1]:= Plus::trace: 1+1 --> 2. >> Out[2]= 2 During evaluation of In[1]:= Sin::argx: Sin called with 2 arguments; 1 argument is expected. >> During evaluation of In[1]:= Message::trace: Message[Sin::argx,Sin,2] --> Null. >> Out[3]= Sin[1,1] In[4]:= Unprotect[Message];

Unable to use Mathematica Link in NetLogo 6.0

白昼怎懂夜的黑 提交于 2019-12-11 09:49:49
问题 I was trying to connect Netlogo 6.0 and Mathematica 11 on my Mac OSX system (v10.11.6). I have followed the installation instructions of the Netlogo Mathematica-Link: import NetLogo.m into Mathematica and load the package, << NetLogo`. The problem is when I try to start NetLogo from Mathematica: NLStart["/Applications/NetLogo 6.0/"] an error message appears "Mathematica could not find your NetLogo installation directory /Applications/NetLogo 6.0/, Would you like to locate it?", I find the

SymbolName applied to a list of variables, some of which may have values assigned

寵の児 提交于 2019-12-11 08:58:23
问题 In Mathematica: I would like to pass a variable number of arguments to a function. I would like to print the name of each argument. The problem is that SymbolName evaluates its input. For a given variable, you can get around this: a=18; SymbolName[Unevaluated[a]] works. But that won't work if the variable is in a list. For example: printname[x__]:=Print[Table[SymbolName[Unevaluated[{x}[[i]]]],{i,1,Length[{x}]}]]; printname[a,b,c] will not work. Any suggestions? Thanks in advance. 回答1:

shadow message in Wolfram Workbench 2.0

£可爱£侵袭症+ 提交于 2019-12-11 08:43:19
问题 I am writing documentation for a package with WB 2.0. Very often, when I create links or insert cells using the documentation tools palette, I get the following message: Global StyleNames::shdw: Symbol StyleNames appears in multiple contexts {Global ,System }; definitions in context Global may shadow or be shadowed by other definitions. >> This message appears even after I start a new session of Workbench - Mathematica. Except for this, everything else seems to work fine. The documentation

how to solve for all non-negative integer xi's in mathematica

给你一囗甜甜゛ 提交于 2019-12-11 08:16:00
问题 I have a problem similar to IntegerPartitions function, in that I want to list all non-negative integer xi 's such that, for a given list of integers {c1,c2,...,cn} and an integer n : x1*c1+x2*c2+...+xn*cn=n Please share your thoughts. Many thanks. 回答1: The built-in function FrobeniusSolve solves the case where the c1, c2, ..., cn are positive integers (and the right hand side is not n): In[1]:= FrobeniusSolve[{2, 3, 5, 6}, 13] Out[1]= {{0, 1, 2, 0}, {1, 0, 1, 1}, {1, 2, 1, 0}, {2, 1, 0, 1},

Mathematica Lists - Search Level Two and Return Level One?

☆樱花仙子☆ 提交于 2019-12-11 07:48:31
问题 I need to string match in the second level of a list but have true cases returned at the first level (there's information in the first level that I need to categorize the returns). First /@ GatherBy[#, #[[3]] &] &@ Cases[#, x_List /; MemberQ[x, s_String /; StringMatchQ[s, ("*PHYSICAL EXAMINATION*"), IgnoreCase -> True]], {2}] &@ Cases[MemoizeTable["Diagnostic_table.txt"], {_, 11111, __}] The GatherBy command at the top is just organizing all the entries by date so I don't get any duplicates.

Adding Alignment to a Manipulate Ouput in Mathematica

∥☆過路亽.° 提交于 2019-12-11 07:19:08
问题 Considering the following : Manipulate[ If[Intersection[Row1, Row2] == {}, Style[Plus @@ {Plus @@ Row1, Plus @@ Row2}, Bold, 20], "Error"], {{Row1, {1}}, {1, 2, 3, 4, 5}, ControlType -> TogglerBar}, {{Row2, {2}}, {1, 2, 3, 4, 5}, ControlType -> TogglerBar} ] - I would like the "3" to be centered, is it possible ? 回答1: Manipulate has its own Alignment option. You can see if that works for you: Manipulate[ If[Intersection[Row1,Row2]=={},Style[Plus@@{Plus@@Row1,Plus@@Row2},Bold,20],"Error"], {