在Julia中向矩阵添加一行? [英] Add a row to a matrix in Julia?
本文介绍了在Julia中向矩阵添加一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Julia中向矩阵添加一行?
How can I add a row to a matrix in Julia?
例如,
mat = [1 2 3; 3 4 2]
,我想在最后添加行x = [4 2 1]
.我试过了:
and I want to add the row x = [4 2 1]
at the end. I tried:
push!(mat, x)
但是它给出了一个错误.
but it gives an error.
推荐答案
对于矩阵的这种连接方式,您可以这样做:
For concatenation of matrix such way you can do so:
mat = [mat;x]
或使用函数垂直串联:
vcat(mat,x)
在文档中了解有关这些操作的更多信息.
Read more about these operations in the documentation.
这篇关于在Julia中向矩阵添加一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文