function shsurv (func, p, varin)
i = 1;
ci = num2str(i);
nntn = nargin -1;
ntn = nntn -1;
va_start ();
while (--nntn)
eval(['tn', ci, ' = va_arg();']);
eval(['[n(', ci, ') k] = size(tn', ci, ');']);
if i == 1
listtn = ['tn', ci,','];
listT = ['T', ci,','];
listf = ['f', ci,','];
listg = ['g', ci,','];
else
listtn = [listtn, ' tn', ci,','];
listT = [listT, ' T', ci,','];
listf = [listf, ' f', ci,','];
listg = [listg, ' g', ci,','];
end
i = i + 1;
ci = num2str(i);
end
[i, nl] = size(listtn); listtn = listtn(1:(nl-1));
[i, nl] = size(listT); listT = listT(1:(nl-1));
[i, nl] = size(listf); listf = listf(1:(nl-1));
[i, nl] = size(listg); listg = listg(1:(nl-1));
p = p(:,1);
global dataset Range all_in_one;
for i = 1:ntn
ci = num2str(i);
eval(['global xlabel', ci, ' ylabel', ci, ';']);
end
if prod(size(dataset)) == 0
dataset = 1:ntn;
end
if prod(size(all_in_one)) == 0
all_in_one = 0;
end
if prod(size(Range)) == 0
Range = zeros (ntn, 2);
for i = 1:ntn
ci = num2str(i);
eval(['r0 = 0.9*min(tn', ci, '(:,1));']);
eval(['r1 = 1.1*max(tn', ci, '(:,1));']);
Range(i,:) = [r0 r1];
end
end
[nr i] = size(Range);
if nr ~= ntn
Range = zeros (ntn, 2);
for i = 1:ntn
ci = num2str(i);
eval(['r0 = 0.9*min(tn', ci, '(:,1));']);
eval(['r1 = 1.1*max(tn', ci, '(:,1));']);
Range(i,:) = [r0 r1];
end
end
for i = 1:ntn
ci = num2str(i);
if eval(['prod(size([xlabel', ci,']) == 0'])
eval(['xlabel', ci, ' = ''time'';']);
end
if eval(['prod(size([ylabel', ci,']) ~= 1'])
eval(['ylabel', ci, ' = ''number'';']);
end
end
nS = max(size(dataset));
for i = 1:ntn
eval(['T', num2str(i), ' = linspace(', ...
num2str(Range(i,1)), ', ', num2str(Range(i,2)), ', 100)';']);
end
eval(['[', listf,'] = ', func, '(p,', listT,' );']);
eval(['[', listg,'] = ', func, '(p,', listtn,' );']);
for i = 1:nS
ci = num2str(dataset(i));
eval(['f', ci, ' = f', ci, '* tn', ci, '(1,2);']);
eval(['g', ci, ' = g', ci, '* tn', ci, '(1,2);']);
end
clf;
if all_in_one ~= 0
for i = 1:nS
ci = num2str(dataset(i));
eval(['plot(T', ci, '(:, 1), f', ci, ', ''r'');']);
eval(['[nr nc] = size(tn', ci, ');']);
eval(['plot(tn', ci, '(:,1), tn', ci, '(:,2), ''b+'');']);
for j = 1:n(dataset(i))
eval(['plot([tn', ci, '(j,[1 1])'],' ...
'[tn', ci, '(j,2); g', ci, '(j)], ''m'');']);
end
if i == 1
eval(['xtext = xlabel',ci,';']);
eval(['xlabel(''', xtext, ''');']);
eval(['ytext = ylabel',ci,';']);
eval(['ylabel(''', ytext, ''');']);
end
end
else
r = max([1, floor(sqrt(ntn))]); k = ceil(nS/r);
for i = 1:nS
subplot(r,k,i)
clf;
ci = num2str(dataset(i));
eval(['xtext = xlabel',ci,';']);
eval(['xlabel(''', xtext, ''');']);
eval(['ytext = ylabel',ci,';']);
eval(['ylabel(''', ytext, ''');']);
eval(['plot(T', ci, '(:, 1), f', ci, ', ''r'');']);
eval(['[nr nc] = size(tn', ci, ');']);
eval(['plot(tn', ci, '(:,1), tn', ci, '(:,2), ''b+'');']);
end
end