“tmp$xxxx”的含义在 Mathematica 输出中
由于谷歌字符串包含 $
(美元符号)是有问题的,我找不到对以下输出的任何解释:
{Cos[tmp$132923 + \[Phi]],
Sin[tmp$132926 + \[Phi]],
\[Phi]
}
问题:
什么是 tmp$xxxx
意味着什么?
一些背景
在 `book2.nb' 中,我定义了以下函数:
g[i_, j_] := {
f1[i, t, f2[b, j], p][[1]],
f1[i, t, f2[b, j], p][[2]],
f3[i, t, p]
}
其中 f1,f2,f3
均在另一个笔记本 book1.nb
中定义,它已初始化并且工作正常。此外,f1
返回一个列表,b
是一个已定义且活动的列表。
现在,当我调用 g[1,1]
时,我会得到类似于上面引用的输出 - 使用这个 tmp$
。尽管如此,如果我尝试绘制 g ,它会完美地工作(使用 ParametricPlot3D[g[1, 1], {t, 0, 1}, {p, 0, 2 Pi}]< /代码>)。但是,如果我尝试定义一个变量
V= {
f1[1, t, f2[b, 1], p][[1]],
f1[1, t, f2[b, 1], p][[2]],
f3[1, t, p]
}
,将 i,j
替换为固定值。然后 V
再次带有 tmp$
元素,但这次它没有绘制...
As it is problematic to google strings which contain $
(dollar sign) I couldn't find any explanation to the following output:
{Cos[tmp$132923 + \[Phi]],
Sin[tmp$132926 + \[Phi]],
\[Phi]
}
The question:
What does tmp$xxxx
means?
Some background
In `book2.nb' I defined the following function:
g[i_, j_] := {
f1[i, t, f2[b, j], p][[1]],
f1[i, t, f2[b, j], p][[2]],
f3[i, t, p]
}
Where f1,f2,f3
are all defined in another notebook book1.nb
, which was initialized and working fine. Furthermore, f1
returns a list and b
is a list defined and active.
Now, when I invoke g[1,1]
I get an output similar to the one cited above - with this tmp$
. Nevertheless, if I try to plot g
it works perfectly (using ParametricPlot3D[g[1, 1], {t, 0, 1}, {p, 0, 2 Pi}]
). However, if I try to define a variable
V= {
f1[1, t, f2[b, 1], p][[1]],
f1[1, t, f2[b, 1], p][[2]],
f3[1, t, p]
}
where I replace i,j
with fixed values. Then V
is once again with a tmp$
element, but this time it DOESN'T plot...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您很可能会看到通过范围界定产生的本地化符号,例如
Module
。这是一个例子。由于本地化符号
x
用于定义全局符号y
,临时符号x$152
转义Module
。此过程还有其他变体。假设您为单元格设置了一个唯一的上下文 (
Evaluation
>Notebook's Default Context
>Unique to Each Cell Group
),然后进行分配到一个明确的全局符号:现在在另一个笔记本中:
You are most likely seeing localized symbols that result through scoping such as
Module
.Here is one example. Since the localized symbol
x
is used to define the global symboly
the temporary symbolx$152
escapesModule
.There are other variations of this process. Suppose you set a unique context for the cell (
Evaluation
>Notebook's Default Context
>Unique to Each Cell Group
) and then make an assignment to an explicitly Global symbol:Now in another notebook:
您的代码可能存在此问题的变体:
此时评估此:
给出此:
通常,这意味着代码存在问题。
要么“t”作为“f”的参数传递:
要么“t”需要以某种方式初始化:
如果您打算这样做,那么在代码中使用这些唯一变量是完全可以的。例如,这是编写具有许多唯一变量的表达式的一种方法:
Your code probably has a variation of this problem:
at which point evaluating this:
gives this:
Often, this means there is a problem with the code.
Either 't' was meant to be passed in as a parameter of 'f':
or 't' needed to be initialized in some fashion:
It's perfectly ok to use these unique variables in your code, if you intend to do so. For example, this is one way to write an expression with with many unique variables: