Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between boolean and logical

Tags:

boolean

matlab

Out of curiosity, if I type these lines in MATLAB:

a = logical([12 0 1.2]);
b = boolean([12 0 1.2]);

The output variables a and b are the same (same value and type). Hence, is there any difference between boolean and logical?

like image 692
tashuhka Avatar asked Feb 26 '14 15:02

tashuhka


1 Answers

A quick look at the boolean function can give you a good answer to your question:

If you type : edit boolean in the matlab console you get:

function y = boolean(x)
%BOOLEAN Creates a boolean vector.
%   This function is typically used in Simulink parameter dialogs, such as
%   the Constant block dialog.  This function generates a logical vector,
%   which is treated as a boolean value in Simulink.  Now that logical is a
%   MATLAB type, this function is essentially just an alias.
%
%   Y = BOOLEAN(X) Converts the vector X into a boolean vector.
%
%   Example: 
%      boolean([0 1 1]) returns [0 1 1]
%
%   See also LOGICAL.

%   Copyright 1990-2012 The MathWorks, Inc.

narginchk(1,1);

if ~isreal(x)
    DAStudio.error('Simulink:utility:BooleanCannotBeComplex');
end

y = logical(x);

If you look at the last line of this function, you can see that the boolean function call the logical function.

like image 108
Etienne Avatar answered Oct 14 '22 18:10

Etienne