全局矩阵有何不同?

发布于 2024-12-20 00:04:14 字数 470 浏览 2 评论 0原文

这计算得很好:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

婴鹅 2024-12-27 00:04:14

您需要首先在基础工作区中将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文