在 MATLAB 中,什么命令可以擦除矩阵中除前三列之外的所有列?
我本质上是试图获取一个矩阵 a,并将其转换为一个矩阵 af,该矩阵的值位于 a 的前三列中。我只想将 a
修剪为仅前三列。
I am essentially trying to take a matrix, a
, and turn it into a matrix af which has the values in the first three columns of a
. I just want to prune a
down to only its first three columns.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这表示“我有一个名为 oldMatrix 的矩阵。我想将该矩阵的子集存储到 newMatrix 中”,括号中的尺寸表示您想要的子集。第一个冒号表示“所有行”,1:3 表示“第 1 列到第 3 列”。
This says "I have a matrix called oldMatrix. I want to store a subset of that matrix into newMatrix" and the dimensions in the parentheses say what subset you want. The first colon signifies "all rows" and the 1:3 signifies "columns 1 through 3".
如果您想删除除前三列之外的所有列,则执行此操作...
如果您只想将前三列复制到新数组中,那么这是正确的...
当然,您始终可以这样做基本上删除最后一列...
一个比另一个更好吗?似乎没有什么区别。
似乎存在很小的(可重复的)差异,但我并不完全相信它是一致的。 MATLAB 的下一个版本可能会改变这些时间。
If you wish to erase all but the first three columns, then do this...
If you wish to copy over only the first three columns into a new array, then this is right...
Of course, you can always do this to essentially erase those last columns...
Is one better than the other? There would seem to be little difference.
There seems to be a small (repeatable) difference, but I'd not totally trust that to be consistent. The next release of MATLAB might change those times.