-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsizeof.m
More file actions
26 lines (22 loc) · 744 Bytes
/
Copy pathsizeof.m
File metadata and controls
26 lines (22 loc) · 744 Bytes
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
function nbytes = sizeof(precision)
%SIZEOF return the number of bytes of a builtin data type.
% NBYTES = SIZEOF(PRECISION) returns the number of bytes of a single
% element of class PRECISION. PRECISION must be the name of one of the
% builtin data types.
%
% Knowing the number of bytes for a datatype is useful when performing
% file I/O where some operations are defined in numbers of bytes.
%
% Example:
% nbytes = sizeof('single');
% Charles Simpson <csimpson at-symbol gmail dot-symbol com>
% 2007-09-26
narginchk(1, 1);
try
z = zeros(1, precision); %#ok, we use 'z' by name later.
catch
error('Unsupported class for finding size');
end
w = whos('z');
nbytes = w.bytes;
end