全局矩阵有何不同?
这计算得很好:
spike(waves0);
但令人惊讶的是,这并没有:
toArff(@spike)
error: A(I): Index exceeds matrix dimension.
error: called from:
error: /Users/simpatico/mlr/spike.m at line 4, column 7
error: /Users/simpatico/mlr/toArff.m at line 4, column 16
function toArff = toArff(features)
global waves0;
spike0 = features(waves0);
true = zeros(size(waves0)(1), 1);
P = [spike0 true];
end
This computes fine:
spike(waves0);
But this surprisingly doesn't:
toArff(@spike)
error: A(I): Index exceeds matrix dimension.
error: called from:
error: /Users/simpatico/mlr/spike.m at line 4, column 7
error: /Users/simpatico/mlr/toArff.m at line 4, column 16
function toArff = toArff(features)
global waves0;
spike0 = features(waves0);
true = zeros(size(waves0)(1), 1);
P = [spike0 true];
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要首先在基础工作区中将
waves0
声明为全局。或者,您可以使用
waves0 = evalin('base', 'waves0');
从基础工作区获取值。请注意,这些选项都不被认为是好的做法,因为它会引起您所看到的问题等问题。将
waves0
作为输入参数传递会更好。You need to declare
waves0
as global in the base workspace first.Alternatively, you can use the
waves0 = evalin('base', 'waves0');
to fetch the value from the base workspace.Note that none of these options are considered to be good practice, since it gives rise to exactly the sort of issue you're seeing, amongst others. It would be much better to pass
waves0
in as an input parameter.