% SECTION 1: Numeric data types
% int8,   int16, int32,   int64
% uint8, uint16, uint32, uint64
% intX  represents integers  -2^(X-1) ... 0 ... 2^(X-1)
% uintX represents integers               0 ... 2^X - 1
%
%
% single  means 'single precision real number'  (4B)
% double  means 'double precision real number'  (8B)
%
clear
format short
a=10;
b=10.0;
c=1e6;
pi;
whos
pi=100;
whos
isinteger(a)
isreal(a)
% DEFINED pi in workspace !! DANGER !! MATLAB's pi is hidden by workspace's pi
pi
clear pi
whos
% erase WORKSPACE's pi !
%
z=input('press any key');
disp('CLEARing workspace and creating new variables below');
clear
whos
au8 = uint8(10);
au16= uint16(10);
au32= uint32(10);
au64= uint64(10);

b8 =  int8(10);
b16=  int16(10);
b32=  int32(10);
b64=  int64(10);
format hex
b8
b16
b32
b64
au8
au16
au32 
au64
format short

csingle =  single(10);
cdouble =  double(10);
c1      =  10;
c2      =  10.0;
whos

int8(127)
int8(128)
int8(-128)
int8(-129)
int8(100000)


z=input('press any key');
disp('SMALLEST LARGEST INTEGERS/ REAL NUMBERS');
intmin
intmax
intmin('int8')
intmax('int8')

intmin('uint16')
intmax('uint16')

realmin
realmax
realmin('single')
realmax('single')

realmin('double')
realmax('double')

% SECTION 2 logical data type and relational operators
z=input('press any key');
disp('CLEARing workspace and creating new variables below: logical data type');
a = (5 > 6)
7 ~= 8

true == false
false == true

try
FALSE == true 
catch
 disp('if you get this message FALSE == true generates an error');
end

disp(' zz =false - true. What is the datatype of zz?');
zz = false - true
whos zz

% SECTION 3 conversion
z=input('press any key');
disp('Integer conversion');
clear

bin2dec('101011')

dec2bin(43)

hex2dec('FF')

hex2dec('2B')

base2dec('2B',16)
base2dec('FF',16)
base2dec('43',10)
base2dec('101011',2)

% SECTION 4 conversion
z=input('press any key');
disp('Precision is not infinite in MATLAB');
clear

5== 5
5== 5.0000000000000000000001
eps(5)
5 == (5+eps(5)/2)
5 == (5+eps(5))
5 == (5+eps(5)-1e-14)
5 == (5+eps(5)-1e-15)

clear



% SECTION 5 : Strings in MATLAB
z=input('press any key');
disp('Precision is not infinite in MATLAB');
clear

a=1234.5
b=12345
c='12345'
d='1234.5'

z1='a'
z2='b'
z3='c'
z1+0
z2+0
z3+0

a=1234.5
b=12345
sa=num2str(a)
sb=num2str(b)

c='12345'
d='1234.5'
nc=str2num(c)
nd=str2num(d)

length(c)
length(d)
length('a')
length(z1)
length('')
length(' ')
length('a')
length(a)

1234 == '1234'

1 == int8(1)

z4='abcdefg'
z4+0
z5='ABCDEFG'
z5+0
z6='0123456789'
z6+0
length(z4)
length(z6)

z7='''''''''';
length(z7)
z7


% Anonymous functions

f = @(x) (x^2 ) 

g= @(x,y) (x^y)

f(5)


g(2,4)

namelengthmax


aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  =9

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =9


round(2.4)
floor(2.1) 
floor(-2.1)
ceil(2.1)
ceil(-2.1)
rand
 round(rand)
 round(10*rand)


