MATLAB中是否可以使用基于零的索引 [英] Is zero based indexing available in MATLAB

查看:256
本文介绍了MATLAB中是否可以使用基于零的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C中n长度数组的索引从0:N-1开始.而在MATLAB中则是1:N

The indexing of an n-length array in C is from 0:N-1. whereas in MATLAB it is from 1:N

现在,我对C风格的索引更满意.是否可以通过在我的MATLAB脚本中包含一些命令或其他命令来告诉MATLAB采用C样式索引而不是传统的1:N索引?

Now, I am more comfortable with the C-style indexing. Is there a way to tell MATLAB, by including some command in my MATLAB scripts or whatever, to adopt a C-style indexing rather than the traditional 1:N indexing?

推荐答案

否,我认为差异在于数学家从1开始计数.(不是MATLAB更适合数学家,相反,MATLAB更适合数学家被工程师更多地使用(与Mathematica或Maple相比,它们的符号处理功能更强大)

No, and i believe the difference stems from the fact that mathematicians start counting from 1. (not that MATLAB is more suited for mathematicians, on the contrary it is used by engineers more (compared to Mathematica or Maple whose symbolic processing is more powerful))

如果您想从零开始编写代码,但类似于MATLAB,请查看 NumPy和SciPy ,Python包.

If you want to code zero based, but similar to MATLAB, look at NumPy and SciPy, Python packages.

另请参见为什么编号应从零开始进行说明一般基于零索引和基于索引的索引,对于MATLAB, MATLAB索引问题具体的讨论.有关讨论,请参见 https://plus.google.com/115212051037621986145/posts/YTUxbXYZyfi 这在Python中.

Also see Why numbering should start at zero for remarks on zero based vs one based indexing in general, and MATLAB indexing issue for a MATLAB specific discussion. See https://plus.google.com/115212051037621986145/posts/YTUxbXYZyfi for a discussion of this in Python.

这篇关于MATLAB中是否可以使用基于零的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆