Mathematica列出X,Y,Z组合的组合 [英] Mathematica Lists Combining X,Y,Z Co-Ordinates
问题描述
我是Mathematica的初学者.我的问题是:我在名为XCORD,YCORD,ZCORD的单独列表中有大量的x,y和z坐标,我想将它们组合在一个列表中
I am a beginner in Mathematica. My question is: I have huge amount of x,y and z co-ordinates in separate lists named XCORD,YCORD,ZCORD and I want to combine them in one list
示例:
如果x坐标列表由XCORD = {x1,x2,x3}
给出,y坐标列表由YCORD = {y1,y2,y3}
给出,而z坐标列表由ZCORD = {z1,z2,z3}
给出,我希望得到一个看起来像这样的坐标列表像这样:
Example:
If the x co-oridinates list is given by XCORD = {x1,x2,x3}
, the y co-ordinates list byYCORD = {y1,y2,y3}
and the z co-ordinates list by ZCORD = {z1,z2,z3}
, I would like to have a resulting list of co-ordinates that looks like this:
{{x1,y1,z1},{x2,y2,z2},{x3,y3,z3}}
推荐答案
您可以使用转置:
XCORD = {x1, x2, x3};
YCORD = {y1, y2, y3};
ZCORD = {z1, z2, z3};
res = Transpose[{XCORD, YCORD, ZCORD}]
==> {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}}
有关使用列表的更多信息,可在此处找到,并且更具体地针对您的问题,此处.
More information about working with lists can be found here, and more specific to your question, here.
请注意(最好是允许)不要以大写字母开头自己的变量.使用变量名的小写开头表示您永远不会与成千上万以大写字母开头的内置符号发生冲突.
Please note that it's better (though it's allowed) not to start any variable of your own with a uppercase letter. Using a lowercase start of your variable name means you'll never get into conflict with the thousands of built-in symbols that all start with an uppercase letter.
这篇关于Mathematica列出X,Y,Z组合的组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!