Graphics Programs Reference
In-Depth Information
% w
d f Floating point notation
% w . d e Exponential notation
\
.
Newlinecharacter
n
where w is the width of the field and d is the number of digits after the decimal point.
Line break isforcedbythe newlinecharacter. The following example prints a formatted
table of sin x vs. x at intervals of 0
.
2:
>>x=0:0.2:1;
>>fori=1:length(x)
fprintf('%4.1f %11.6f\n',x(i),sin(x(i)))
end
0.0
0.000000
0.2
0.198669
0.4
0.389418
0.6
0.564642
0.8
0.717356
1.0
0.841471
1.7
Array Manipulation
Creating Arrays
Welearnedbeforethat anarray canbecreatedbytyping its elements betweenbrackets:
>>x=[00.250.50.751]
x=
0
0.2500
0.5000
0.7500
1.0000
Colon Operator
Arrays with equally spaced elements can also beconstructedwith the colon operator.
x = first elem : increment : last elem
For example,
>>x=0:0.25:1
x=
0
0.2500
0.5000
0.7500
1.0000
Search WWH ::




Custom Search