comparison toolboxes/FullBNT-1.0.7/KPMtools/matprint.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
1 % MATPRINT - prints a matrix with specified format string
2 %
3 % Usage: matprint(a, fmt, fid)
4 %
5 % a - Matrix to be printed.
6 % fmt - C style format string to use for each value.
7 % fid - Optional file id.
8 %
9 % Eg. matprint(a,'%3.1f') will print each entry to 1 decimal place
10
11 % Peter Kovesi
12 % School of Computer Science & Software Engineering
13 % The University of Western Australia
14 % pk @ csse uwa edu au
15 % http://www.csse.uwa.edu.au/~pk
16 %
17 % March 2002
18
19 function matprint(a, fmt, fid)
20
21 if nargin < 3
22 fid = 1;
23 end
24
25 [rows,cols] = size(a);
26
27 % Construct a format string for each row of the matrix consisting of
28 % 'cols' copies of the number formating specification
29 fmtstr = [];
30 for c = 1:cols
31 fmtstr = [fmtstr, ' ', fmt];
32 end
33 fmtstr = [fmtstr '\n']; % Add a line feed
34
35 fprintf(fid, fmtstr, a'); % Print the transpose of the matrix because
36 % fprintf runs down the columns of a matrix.