Hi,
I am using the invoke function in Matlab to handle the objects and their methods in Matlab. For example I have the following code to create a discrete labeled node:
function [ node ] = invokeDiscreteNodeLabeled(LabelCollection,domain,nodename)
% LabelCollection is a Matlab cell containing the labels for the states
% of the node
% domain is the domain of the BN we consider
% nodename is the name of the node
nstates=length(LabelCollection);
node=invoke(domain,'GetNewNode','hCategoryChance','hKindDiscrete');
set(node,'Name',nodename);
set(node,'Label',nodename);
set(node,'SubType','hSubtypeLabel');
set(node,'NumberOfStates',nstates);
for i=1:nstates
set(node,'StateLabel',i-1,LabelCollection{i});
end
end
The above code works perfectly but when I try to do the same to create a boolean node I get the following error
Error using Interface.HUGIN_API_ActiveX_Server_7.3.Node/set
Invoke Error, Dispatch Exception:
Source: HAPI
Description: An API function was called with an invalid argument (e.g., a NULL object was passed to a
function that expects a non-NULL argument).
Error in invokeDiscreteBooleanNode (line 7)
set(node,'SubType','hSubtypeBoolean');
The code for the boolean node is the following:
function [ node ] = invokeDiscreteBooleanNode(domain,nodename)
%invokeDiscreteBooleanNode Create a boolean node
node=invoke(domain,'GetNewNode','hCategoryChance','hKindDiscrete');
set(node,'Name',nodename);
set(node,'Label',nodename);
set(node,'SubType','hSubtypeBoolean');
end
Thank you in advance for your answer !