什么是"索引应该是正整数(不是复数格式整数)"在MATLAB?

时间:2014-05-14 07:08:32

标签: matlab

// I made function like this:
function y = ZL(L,f)
if isvector(f)
    y=1j*2*pi.*f*L;
else
    y=1j*2*pi.*f*L;
end

//和命令:     L = 10,     f = -10000:100:10000,     ZL = ZL(L,F);

// then error : 
index should be positive integer(not complex format integer) or boolean
-> this error is translated by me who is Korean; sorry

what's wrong with it?

1 个答案:

答案 0 :(得分:3)

首次致电ZL = ZL(L,f)时,您不会收到任何错误。

如果您尝试再次拨打命令,则会收到此错误:Index exceeds matrix dimensions。这是因为你影响了变量ZL,所以第二次它不是你正在调用的函数但是你正在尝试从数组中获取元素{{1 }}

因此,请不要对变量和现有函数使用相同的名称,否则函数名称将被变量屏蔽。