// 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?
答案 0 :(得分:3)
首次致电ZL = ZL(L,f)
时,您不会收到任何错误。
如果您尝试再次拨打命令,则会收到此错误:Index exceeds matrix dimensions
。这是因为你影响了变量ZL
,所以第二次它不是你正在调用的函数但是你正在尝试从数组中获取元素{{1 }}
因此,请不要对变量和现有函数使用相同的名称,否则函数名称将被变量屏蔽。