如何将列表转换为数组?
我有一个列表和一个(2×2)数组。
我想将列表的前两个值与下面所示的数组“k”相乘,
(当然是将这两个值转换为(2 x 1)数组)。
然后我想对接下来的两个值(即第二个和第三个值)执行相同的过程。
就像 [1,2] ,然后 [2,3] ...[3,4] [4,5] ...( 这些每对列表必须位于 2 x 1 数组中,以便我可以进一步将其相乘与下面提到的k(2×2数组))
所有情况下的数组“k”都是相同的。
如何制作这个循环?
my_List = [1, 2, 3, 4, 5, 6, 7, 8,9, 10, 11, 12, 13,14, 15, 16, 17 ,18 ,19, 20, 21, 22, 23, 24, 25, 26,27 ,28 ,29, 30, 31 ,32, 33, 34,35 ,36, 37, 38, 39]
E = 1
I = 1
l = 1
k = np.array( [ [4*E*I/ l, 2*E*I/ l ],
[2*E*I/ l, 4*E*I/ l ] ] )
I have a list and a (2 by 2) array.
I want to multiply the first two values of the list with this array 'k' shown below,
(of course by converting these two values into a (2 by 1) array).
Then I want to do the same procedure with the next two values( i.e 2nd and 3rd values).
its like [1,2] , then [2,3] ...[3,4] [4,5] ...( these each couple of lists must be in 2 by 1 array so that I can further multiply it with k (2 by 2 array) mentioned below )
The array 'k' in all the cases is the same.
How do I make this loop?
my_List = [1, 2, 3, 4, 5, 6, 7, 8,9, 10, 11, 12, 13,14, 15, 16, 17 ,18 ,19, 20, 21, 22, 23, 24, 25, 26,27 ,28 ,29, 30, 31 ,32, 33, 34,35 ,36, 37, 38, 39]
E = 1
I = 1
l = 1
k = np.array( [ [4*E*I/ l, 2*E*I/ l ],
[2*E*I/ l, 4*E*I/ l ] ] )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您正在寻找的解决方案吗?如果没有添加一些预期的输出,以便可以进行相应的编辑。
测试:
打印输出:
Is this the solution you are looking for? If not add some expected output so that this can be edited accordingly.
Test:
Outputs of print: