gpt4 book ai didi

julia - 向 Julia 中的矩阵添加一行?

转载 作者:行者123 更新时间:2023-12-01 15:21:23 29 4
gpt4 key购买 nike

如何在 Julia 的矩阵中添加一行?

例如,

mat = [1 2 3; 3 4 2]

我想添加行 x = [4 2 1]在末尾。我试过:
push!(mat, x)

但它给出了一个错误。

最佳答案

对于矩阵的串联,您可以这样做:

mat = [mat;x]

或者使用函数垂直串联:
vcat(mat,x)

documentation 中阅读有关这些操作的更多信息.

关于julia - 向 Julia 中的矩阵添加一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36727839/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com