如何在Julia中删除矩阵行 [英] How to delete a row of matrix in julia
问题描述
在matlab中,删除矩阵A的第二行是
In matlab, deleting the 2nd row of matrix A is
A(2,:) = [];
A(2,:) = [];
如何在Julia中删除矩阵行?我尝试使用A(2,:) = []
.但我失败了如何解决这个问题?
How to delete a row of matrix in julia? I tried to use A(2,:) = []
. but I failed. How to solve this problem?
推荐答案
您不能从矩阵中删除行-Matlab对此具有简单语法的事实有点陷阱,因为您必须使用实际的方法删除一行是为了创建不包含该行的副本,因此我们决定将其明确化,从而具有更透明的性能特征.您可以更改一维数组的大小,例如做push!(v,x)
和pop!(v)
.
You can't delete a row from a matrix – the fact that Matlab has easy syntax for this is a bit of a trap because the actual way you have to delete a row is to create a copy without the row so we decided to make that explicit and thereby have more transparent performance characteristics. You can change the size of 1-dimensional arrays, e.g. doing push!(v,x)
and pop!(v)
.
这篇关于如何在Julia中删除矩阵行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!