Hi @Thomas,
In MATLAB, neural networks often output continuous values in the range of [0, 1], especially when dealing with binary classification problems. This means that your network is likely returning probabilities, which need to be converted into boolean values (0 or 1) for your specific application. You can apply a simple threshold to convert the output from double to boolean. A common approach is to use 0.5 as the cutoff:
function [y1] = myNeuralNetworkFunction(x1) % Get output from neural network output = neuralNetworkModel(x1); % Assuming neuralNetworkModel is your trained model
% Convert to boolean based on threshold y1 = output >= 0.5; % This will return true (1) for values >= 0.5 and false (0) otherwise end
If you prefer, you can explicitly convert the output to a logical type:
y1 = logical(output >= 0.5);
For more information on logical function, please refer to
https://www.mathworks.com/help/matlab/ref/logical.html?s_tid=doc_ta
Make sure that your neural network is appropriately configured for binary classification. If you're using a sigmoid activation function in the final layer, this should naturally yield outputs between 0 and 1.
Hope this helps.