1/0
ans =
Inf
clear
0/0
ans =
NaN
h=1.0546e-34
h =
1.0546e-34
h^10
ans =
0
disp('Underflow')
Underflow
h^(-10)
ans =
Inf
% overflow
1/h^10
ans =
Inf
(1/3)+(1/3)+(1/3)-1
ans =
0
(1/3)+(1/3)+(1/3)+(1/3)+(1/3)+(1/3)-2
ans =
-2.2204e-16
(1000/3)+(1000/3)+(1000/3)+(1000/3)+(1000/3)+(1000/3)-2000
ans =
-2.2737e-13
eps(1)
ans =
2.2204e-16
eps(1000)
ans =
1.1369e-13
sin(10*pi)
ans =
-1.2246e-15
sin(10000000000000000*pi)
ans =
-0.3752
cos1=cos(10*pi)
cos1 =
1
cos1-1
ans =
0
cos1=cos(10000000000000000*pi)
cos1 =
0.9269
cos1=cos(100000000000000000*pi)
cos1 =
-0.5300
error=cos1-1
error =
-1.5300
% Precedence
% ^
% * /
% + -
2+3/4
ans =
2.7500
2+(3/4)
ans =
2.7500
(2+3)/4
ans =
1.2500
12/2*3
ans =
18
12/(2*3)
ans =
2
(12/2)*3
ans =
18
clear
x=1
x =
1
y=2
y =
2
x=y; y=x;
x=1
x =
1
x=y
x =
2
x=1
x =
1
xSaved=x
xSaved =
1
y=x
y =
1
clear
x=1
x =
1
y=2
y =
2
xSaved=x
xSaved =
1
x=y
x =
2
y=xSaved
y =
1
pi
ans =
3.1416
pi=3.2
pi =
3.2000
pi*1^2
ans =
3.2000
clear pi
pi
ans =
3.1416
sqr(3)
ans =
9
sqrTry
start of sqrTry
ans =
9
y =
4
y2 =
16
sqrTry
start of sqrTry
3 sqr(3)
if system_dependent('IsDebugMode')==1, dbquit; end
clear
sqrTry
start of sqrTry
2 sqr(3)
if system_dependent('IsDebugMode')==1, dbstep in; end
if system_dependent('IsDebugMode')==1, dbstep; end
if system_dependent('IsDebugMode')==1, dbstep; end
if system_dependent('IsDebugMode')==1, dbstep; end
if system_dependent('IsDebugMode')==1, dbstep; end
ans =
9
if system_dependent('IsDebugMode')==1, dbstep; end
y =
4
if system_dependent('IsDebugMode')==1, dbstep in; end
if system_dependent('IsDebugMode')==1, dbstep; end
if system_dependent('IsDebugMode')==1, dbstep; end
if system_dependent('IsDebugMode')==1, dbstep; end
if system_dependent('IsDebugMode')==1, dbstep; end
y2 =
16
if system_dependent('IsDebugMode')==1, dbquit; end
%% ARRAYS
list=[1 2 4 9 16]
list =
1 2 4 9 16
who list
Your variables are:
list
whos list
Name Size Bytes Class Attributes
list 1x5 40 double
list
list =
1 2 4 9 16
sqrt(list)
ans =
1.0000 1.4142 2.0000 3.0000 4.0000
list=[0 30 45 60 90]
list =
0 30 45 60 90
sind(list)
ans =
0 0.5000 0.7071 0.8660 1.0000
cosd(list)
ans =
1.0000 0.8660 0.7071 0.5000 0
tand(list)
ans =
0 0.5774 1.0000 1.7321 Inf
list
list =
0 30 45 60 90
% make a column
list'
ans =
0
30
45
60
90
list2=[0; 30; 45; 60; 90]
list2 =
0
30
45
60
90
list2'
ans =
0 30 45 60 90
list''
ans =
0 30 45 60 90
list=[1 2 3 4 5 6 7 8 9 10]
list =
Columns 1 through 8
1 2 3 4 5 6 7 8
Columns 9 through 10
9 10
% [START:END]
list=[1:10]
list =
Columns 1 through 8
1 2 3 4 5 6 7 8
Columns 9 through 10
9 10
% [START:STEP:END]
list=[1:1:10]
list =
Columns 1 through 8
1 2 3 4 5 6 7 8
Columns 9 through 10
9 10
list=[-2:2:12]
list =
-2 0 2 4 6 8 10 12
[1 2 3 4 5]
ans =
1 2 3 4 5
set=[1 2 3 4 5]
set =
1 2 3 4 5
count=[1 2 3 4 5]
count =
1 2 3 4 5
sqrt(count)
ans =
1.0000 1.4142 1.7321 2.0000 2.2361
sqr(count)
{Error using *
Inner matrix dimensions must agree.
Error in sqr (line 3)
x2=x*x;}
sqr(3)
ans =
9
sqr(count)
ans =
1 4 9 16 25
count=[1 2 3 4 5]
count =
1 2 3 4 5
sqr(count)
ans =
1 4 9 16 25
sqrDot(count)
{Error using *
Inner matrix dimensions must agree.
Error in sqrDot (line 3)
x2=x*x;}
sqrDot(count)
ans =
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
sqrDot(count')
ans =
55
sqrDot(count)
ans =
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
mod(5,3)
ans =
2
5%3
ans =
5