Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

CRC.Press A Guide to MATLAB Object Oriented Programming May.2007 Episode 2 Part 3 doc
MIỄN PHÍ
Số trang
20
Kích thước
890.3 KB
Định dạng
PDF
Lượt xem
1580

CRC.Press A Guide to MATLAB Object Oriented Programming May.2007 Episode 2 Part 3 doc

Nội dung xem thử

Mô tả chi tiết

214 A Guide to MATLAB Object-Oriented Programming

28 case 'Color'

29 if isempty(this)

30 varargout = {};

31 else

32 varargout = cell(size(this)); % trick next function's

nargout

33 % either index(2:end) or varargin{1} should be empty

34 [do_sub_indexing, do_assignin, this, varargout{:}] =

...

35 Color_helper('get', this, [index(2:end)

varargin{:}]);

36 end

37 case 'LineWidth'

38 if isempty(this)

39 varargout = {};

40 else

41 varargout = {this.mLineWidth};

42 end

43 case 'LineHandle'

44 if isempty(this)

45 varargout = {};

46 else

47 varargout = {this.mLineHandle};

48 end

49 otherwise

50 found = false; % didn't find it in the public section

51 end

52

53 % concealed member variables, not strictly public

54 if ~found && called_by_name

55 found = true;

56 switch index(1).subs

57 case 'mDisplayFunc' % class-wizard reserved field

58 if isempty(this)

59 varargout = {};

60 else

61 varargout = {this.mDisplayFunc};

62 end

63 otherwise

64 found = false; % didn't find it in the concealed section

65 end

66 end

67

68 % parent forwarding block

69 if ~found

70 if called_by_name

71 forward_index = index(1).subs;

C911X_C016.fm Page 214 Friday, March 30, 2007 11:42 AM

General Assignment and Mutator Helper Functions 215

72 else

73 forward_index = index;

74 end

75

76 if nargout == 0

77 varargout = cell(size(this));

78 else

79 varargout = cell(1, nargout);

80 end

81

82 for parent_name = parent_list' % loop over parent cellstr

83 try

84 parent = [this.(parent_name{1})];

85 [varargout{:}] = get(parent, forward_index,

varargin{:});

86 found = true; % catch will assign false if not found

87 do_sub_indexing = false; % assume parent did all sub￾indexing

88 break; % can only get here if field is found

89 catch

90 found = false;

91 err = lasterror;

92 switch err.identifier

93 case 'MATLAB:nonExistentField'

94 % NOP

95 otherwise

96 rethrow(err);

97 end

98 end

99 end

100 if do_assignin

101 parent = num2cell(parent);

102 [this.(parent_name{1})] = deal(parent{:});

103 end

104 end

105

106 % error checking

107 if ~found

108 error('MATLAB:nonExistentField', ...

109 'Reference to non-existent field identifier %s', ...

110 index(1).subs);

111 end

112

113 % nargout adjustment

114 if length(varargout) > 1 & nargout <= 1

115 if iscellstr(varargout) || any([cellfun('isempty',

varargout)])

C911X_C016.fm Page 215 Friday, March 30, 2007 11:42 AM

Tải ngay đi em, còn do dự, trời tối mất!