-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfm_disp.m
135 lines (125 loc) · 2.95 KB
/
fm_disp.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
function output = fm_disp(varargin)
% FM_DISP display messages
%
% OUTPUT = FM_DISP(VARARGIN)
%
%Author: Federico Milano
%Date: 11-Nov-2002
%Update: 02-Feb-2003
%Update: 09-Jul-2003
%Version: 1.0.3
%
%E-mail: [email protected]
%Web-site: faraday1.ucd.ie/psat.html
%
% Copyright (C) 2002-2019 Federico Milano
global Fig History Hdl Settings Theme clpsat
if clpsat.init && ~clpsat.mesg
return
end
% check inputs
% ----------------------------------------------------------
switch nargin
case 0,
testo = {' '};
colore = 1;
case 1,
testo = varargin{1};
colore = 1;
case 2,
testo = varargin{1};
colore = varargin{2};
otherwise,
testo = 'Improper call to function "fm_disp"';
colore = 2;
end
% size of input text/data
% ----------------------------------------------------------
[a,b] = size(testo);
% format text if input is a cell array
% ----------------------------------------------------------
if iscell(testo) && b > 1
d = testo;
testo = cell(a,1);
testo{1,1} = '';
for i = 1:a,
for j = 1:b,
testo{i,1} = [testo{i,1},fvar([' ',d{i,j}],14)];
end
end
end
% actions for string/numeric input
% ----------------------------------------------------------
if ischar(testo),
testo = cellstr(testo);
end
if isnumeric(testo)
d = testo;
string = '';
testo = cell(a,1);
for i = 1:b % liulin122
temp1 = num2str(d(:,i)');
temp2 = findstr(temp1, '.');
if ~isempty(temp2)
string = [string, ' %-13.4f'];
else
string = [string, ' %-13.0f'];
end
end
for i = 1:a,
testo{i,1} = sprintf(string,d(i,:));
end
end
%if isnumeric(testo)
% d = testo;
% string = '';
% testo = cell(a,1);
% for i = 1:b,
% string = [string, ' %-13.4f'];
% end
% for i = 1:a,
% testo{i,1} = sprintf(string,d(i,:));
% end
%end
% display last text row on the main window bar
% ----------------------------------------------------------
if ishandle(Fig.main)
switch colore
case 1,
set(Hdl.text, ...
'String', testo{end,1}, ...
'ForegroundColor', Theme.color05);
case 2,
set(Hdl.text, ...
'String', testo{end,1}, ...
'ForegroundColor', Theme.color07);
if Settings.beep, beep, end
case 3,
set(Hdl.text, ...
'String', testo{end,1}, ...
'ForegroundColor', Theme.color05);
end
drawnow;
end
% resize History.text cell array and display on workspace
% ----------------------------------------------------------
if colore < 3
History.text = [History.text; testo];
len = length(History.text);
if len > History.Max,
History.text = History.text(len-History.Max+1:end);
end
if ishandle(Fig.hist),
set(Hdl.hist, 'String', History.text);
end
if History.workspace || clpsat.init,
if Settings.matlab && Settings.hostver >= 7.14,
disp(char(testo))
else
disp(strvcat(testo))
end
end
end
% output formatted text
% ----------------------------------------------------------
if nargout > 0, output = testo; end