0001 function N = num_lights(ax)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if nargin == 1 && ischar(ax) && strcmp(ax,'UNIT_TEST'), do_unit_test; return,end
0017
0018 if nargin < 1
0019 ax = gca;
0020 end
0021 ch = get(ax, 'Children');
0022
0023
0024 ver= eidors_obj('interpreter_version');
0025 if ver.isoctave
0026
0027 N = sum(strcmp(get(ch, 'type'), 'light'));
0028 else
0029 N = 0;
0030 for i = 1:numel(ch)
0031 N = N + isa(ch(i),'matlab.graphics.primitive.Light');
0032 end
0033 end
0034
0035 function do_unit_test
0036 clf
0037 subplot(211)
0038 plot(rand(5));
0039 camlight('left')
0040 camlight('right')
0041 ax = gca;
0042 unit_test_cmp('current axis', num_lights, 2);
0043 subplot(212)
0044 unit_test_cmp('specific axis', num_lights(ax), 2);
0045