-
Notifications
You must be signed in to change notification settings - Fork 1
/
r8mat_print_some.m
72 lines (54 loc) · 1.42 KB
/
r8mat_print_some.m
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
function r8mat_print_some ( m, n, a, ilo, jlo, ihi, jhi, title )
%*****************************************************************************80
%
%% R8MAT_PRINT_SOME prints out a portion of an R8MAT.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Parameters:
%
% Input, integer M, N, the number of rows and columns of the matrix.
%
% Input, real A(M,N), an M by N matrix to be printed.
%
% Input, integer ILO, JLO, the first row and column to print.
%
% Input, integer IHI, JHI, the last row and column to print.
%
% Input, string TITLE, an optional title.
%
incx = 5;
if ( 0 < s_len_trim ( title ) )
fprintf ( 1, '\n' );
fprintf ( 1, '%s\n', title );
end
for j2lo = max ( jlo, 1 ): incx : min ( jhi, n )
j2hi = j2lo + incx - 1;
j2hi = min ( j2hi, n );
j2hi = min ( j2hi, jhi );
inc = j2hi + 1 - j2lo;
fprintf ( 1, '\n' );
fprintf ( 1, ' Col: ' );
for j = j2lo : j2hi
fprintf ( 1, '%7d ', j );
end
fprintf ( 1, '\n' );
fprintf ( 1, ' Row\n' );
i2lo = max ( ilo, 1 );
i2hi = min ( ihi, m );
for i = i2lo : i2hi
fprintf ( 1, '%7d ', i );
for j = j2lo : j2hi
if ( a(i,j) == floor ( a(i,j) ) )
fprintf ( 1, '%8d ', a(i,j) );
else
fprintf ( 1, '%12g ', a(i,j) );
end
end
fprintf ( 1, '\n' );
end
end
return
end