File: array_zeros.html

package info (click to toggle)
freemat 4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 174,756 kB
  • ctags: 67,023
  • sloc: cpp: 351,059; ansic: 255,892; sh: 40,590; makefile: 4,387; perl: 4,058; asm: 3,313; pascal: 2,718; fortran: 1,722; ada: 1,681; ml: 1,360; cs: 879; csh: 795; python: 430; sed: 162; lisp: 160; awk: 5
file content (105 lines) | stat: -rw-r--r-- 2,203 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<HTML>
<HEAD>
<TITLE>ZEROS Array of Zeros
</TITLE>
</HEAD>
<BODY>
<H2>ZEROS Array of Zeros
</H2>
<P>
Section: <A HREF=sec_array.html> Array Generation and Manipulations </A>
<H3>Usage</H3>
Creates an array of zeros of the specified size.  Two seperate 
syntaxes are possible.  The first syntax specifies the array 
dimensions as a sequence of scalar dimensions:
<PRE>
   y = zeros(d1,d2,...,dn).
</PRE>
<P>
The resulting array has the given dimensions, and is filled with
all zeros.  The type of <code>y</code> is <code>double</code>, a 64-bit floating
point array.  To get arrays of other types, use the typecast 
functions (e.g., <code>uint8</code>, <code>int8</code>, etc.).  An alternative syntax
is to use the following notation:
<PRE>
   y = zeros(d1,d2,...,dn,classname)
</PRE>
<P>
where <code>classname</code> is one of 'double', 'single', 'int8', 'uint8',
'int16', 'uint16', 'int32', 'uint32', 'int64', 'uint64', 'float', 'logical'.  
    
The second syntax specifies the array dimensions as a vector,
where each element in the vector specifies a dimension length:
<PRE>
   y = zeros([d1,d2,...,dn]),
</PRE>
<P>
or
<PRE>
   y = zeros([d1,d2,...,dn],classname).
</PRE>
<P>
This syntax is more convenient for calling <code>zeros</code> using a 
variable for the argument.  In both cases, specifying only one
dimension results in a square matrix output.
<H3>Example</H3>
The following examples demonstrate generation of some zero arrays 
using the first form.
<PRE>
--&gt; zeros(2,3,2)

ans = 

(:,:,1) = 
 0 0 0 
 0 0 0 

(:,:,2) = 
 0 0 0 
 0 0 0 

--&gt; zeros(1,3)

ans = 
 0 0 0 
</PRE>
<P>
The same expressions, using the second form.
<PRE>
--&gt; zeros([2,6])

ans = 
 0 0 0 0 0 0 
 0 0 0 0 0 0 

--&gt; zeros([1,3])

ans = 
 0 0 0 
</PRE>
<P>
Finally, an example of using the type casting function <code>uint16</code> to generate an array of 16-bit unsigned integers with zero values.
<PRE>
--&gt; uint16(zeros(3))

ans = 
 0 0 0 
 0 0 0 
 0 0 0 
</PRE>
<P>
Here we use the second syntax where the class of the output is specified 
explicitly
<PRE>
--&gt; zeros(3,'int16')

ans = 
 0 0 0 
 0 0 0 
 0 0 0 
</PRE>
<P>
</BODY>
</HTML>