问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/8414283/how-is-a-global-matrix-different