linspace(0,0,100)类似于
C++中的 int a[100]={0};
函数定义
fun = @(x,y)(x^2+y^2)
可以用来快捷定义一个函数,用fun(1,2)来进行调用。
此外,matlab可以通过 nargin 来判断构造函数中传递了几个参数。
下面的代码是类似于c++的重载构造函数的操作。
function this = CircleArr(front,rear, MAXSIZE)
if nargin == 3
this.m_front = front;
this.m_rear = rear;
this.m_MAXSIZE = MAXSIZE;
this.m_arr = linspace(0, 0, MAXSIZE);
end
end