wolfram-mathematica - 数学 : How to apply function to a certain column of a table

标签 wolfram-mathematica

我想将函数应用于表的特定列。说到 (m x n) 表的第 i 列。实际上,我只想将该列中的所有元素与标量相乘,但是通用函数的应用也可以。

它可能只需要一些 Map 或 MapAt 命令,可能与 Transpose 结合使用以应用于行而不是列 - 但我无法找出寻址整个列(或行)的正确语法..

任何提示将不胜感激。

最佳答案

这是一个 3x3 表:

In[1]:= table = {{1,2,3}, {4,5,6}, {7,8,9}}
Out[1]= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
In[2]:= table//TableForm
Out[2]//TableForm= 1   2   3
                   4   5   6
                   7   8   9
第 2 列是 table[[All, 2]] :
In[3]:= table[[All, 2]]
Out[3]= {2, 5, 8}

所以只修改那一列是一件很简单的事情:
In[4]:= table[[All, 2]] = 10 * table[[All, 2]]
Out[4]= {20, 50, 80}
In[5]:= table//TableForm
Out[5]//TableForm= 1   20   3
                   4   50   6
                   7   80   9

关于wolfram-mathematica - 数学 : How to apply function to a certain column of a table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4570652/

相关文章:

image-processing - 在没有X11的机器上(即,不涉及前端)将绘图作为Mathematica中的图像导出。

在 Mathematica/Mathlink 中计算导数

function - 计算 Mathematica 列表中的出现次数(使用代码,但未完全正常工作)

wolfram-mathematica - 如何加速动态显示带有自定义刻度的图形?

excel - 电力运营商不一致

wolfram-mathematica - 使用 Mathematica 生成晶格

wolfram-mathematica - 数学 : Labels and absolute positioning

wolfram-mathematica - 输出为 "Private` "Mathematica 包中的内容

python - 如何用Python(Sympy)实现一个函数,实现与Wolfram Mathematica中的ToExpression相同的功能?

plot - IJulia 情节 One Liner