error: can't perform indexing operations for <unknown type> type when sourcing
error: can't perform indexing operations for <unknown type> type when sourcing
用这个代码,保存为test.m
function test()
x = 1;
endfunction
在 GUI 中通过 source(test.m)
获取它时,我收到以下错误消息:
>> clear
>> source (test.m)
x = 1
error: can't perform indexing operations for <unknown type> type
error: evaluating argument list element number 1
>>
通过 >> test
调用函数测试工作正常,但我想知道我在这里做错了什么。
进度:
只调用测试,在正确的目录中似乎可以,但是我们要采购什么?
如果你运行
source(test.m)
解释器尝试计算“.”。变量 "test" 的下标(在您的情况下是一个函数),然后用结果调用 source
。
你想要的是用字符串 "test.m" 调用函数 source
所以你必须使用引号:
source ("test.m")
或者不使用 () 在这种情况下所有参数都作为字符串传递:
source test.m
用这个代码,保存为test.m
function test()
x = 1;
endfunction
在 GUI 中通过 source(test.m)
获取它时,我收到以下错误消息:
>> clear
>> source (test.m)
x = 1
error: can't perform indexing operations for <unknown type> type
error: evaluating argument list element number 1
>>
通过 >> test
调用函数测试工作正常,但我想知道我在这里做错了什么。
进度:
只调用测试,在正确的目录中似乎可以,但是我们要采购什么?
如果你运行
source(test.m)
解释器尝试计算“.”。变量 "test" 的下标(在您的情况下是一个函数),然后用结果调用 source
。
你想要的是用字符串 "test.m" 调用函数 source
所以你必须使用引号:
source ("test.m")
或者不使用 () 在这种情况下所有参数都作为字符串传递:
source test.m