楼主: Lisrelchen
850 3

[Matlab-Based Book]A Guide to MATLAB Object-Oriented Programming [推广有奖]

  • 0关注
  • 62粉丝

VIP

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
50057 个
通用积分
79.9387
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
结果:找到“A Guide to MATLAB Object-Oriented Programming”相关内容5个,排序为按回复时间降序,搜索更多相关帖子请点击“高级
A Guide to MATLAB Object-Oriented Programming
1 个回复 - 1014 次查看2014-5-20 11:14 - huangxl@oriza - S-Plus&R专版

A Guide to MATLAB Object-Oriented Programming
7 个回复 - 1579 次查看A Guide to MATLAB Object-Oriented Programming Publisher: TF-CHPMNNumber Of Pages: 384Publication Date: 2007-05-14Sales Rank: 241864ISBN / ASIN: 158488911XEAN: 9781584889113Binding ...2007-7-13 11:39 - zhushiyou - Matlab及其他计量软件专版

[下载]A Guide to MATLAB Object Oriented Programming
6 个回复 - 3286 次查看已经有人发过,但是没有什么介绍,我在这里再介绍一下这本书。觉得有参考价值你才有阅读的必要,对吧?This book makes two assumptions about you, the reader. The first assumption is that you consider yoursel ...2008-9-28 05:31 - riversmall - Matlab及其他计量软件专版

A Guide to MATLAB Object-Oriented Programming国外新书
4 个回复 - 2434 次查看一共二十四章,382页,贴出几章的目录,太多了,没贴完,最近想买东西缺钱,论坛上的东西实在是太贵了,所以就收一点.人格担保好书不贵,大家就当救济了Chapter 1Introduction............................................. ...2008-1-2 18:11 - sofer - Matlab及其他计量软件专版

A Guide to MATLAB Object Oriented Programming
7 个回复 - 1483 次查看[此贴子已经被作者于2008-1-17 4:14:32编辑过]2008-1-5 22:54 - bobojin - Matlab及其他计量软件专版


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Programming Oriented Program MATLAB object

沙发
Lisrelchen 发表于 2016-3-21 06:45:53 |只看作者 |坛友微信交流群
  1. function this = cShape
  2. % A Comprehensive Guide to Object Oriented Programming in MATLAB
  3. %   Chapter 5 example Constructor
  4. %   (c) 2004 Andy Register
  5. this = struct( ...
  6.     'mSize', ones(2,1),  ... % scaled [width height]’ of bounding box
  7.     'mScale', ones(2,1), ... % [width height]’ scale factor
  8.     'mColorHsv', rgb2hsv([0 0 1])', ... % [Hue Saturation Color]’ of border, default is blue
  9.     'mDisplayFunc', [] ... % alternate display function fun(this, display_name)
  10.     );
  11. this = class(this, 'cShape');
  12. superiorto('double')
复制代码

使用道具

藤椅
Lisrelchen 发表于 2016-3-21 06:46:43 |只看作者 |坛友微信交流群
  1. function display(this, display_name)
  2. % A Comprehensive Guide to Object Oriented Programming in MATLAB
  3. %   Chapter 5 example display
  4. %   (c) 2004 Andy Register

  5. if nargin < 2
  6.     % assign 'ans' if inputname(1) empty
  7.     display_name = inputname(1);
  8.     if isempty(display_name)
  9.         display_name = 'ans';
  10.     end
  11. end

  12. % check whether mDisplayFunc has a value
  13. % if it has a value feval the value to get the display
  14. use_standard_view = cellfun('isempty', {this(:).mDisplayFunc});
  15. if all(use_standard_view)
  16.     standard_view(this, display_name);
  17. else
  18.     for k = 1:length(this(:))
  19.         if use_standard_view(k)
  20.             standard_view(this(k), display_name);
  21.         else
  22.             indexed_display_name = sprintf('%s(%d)', display_name, k);
  23.             feval(this(k).mDisplayFunc, this(k), indexed_display_name);
  24.         end
  25.     end   
  26. end

  27. % --------------------------
  28. function standard_view(this, display_name)
  29. if ~isempty( ...
  30.         [strfind(display_name, '.') ...
  31.         strfind(display_name, '(') ...
  32.         strfind(display_name, '{')])
  33.     display_name = 'ans';
  34. end
  35. % handle a scalar vs array object
  36. % note: [] this jumps to else
  37. if length(this) == 1  % scalar case
  38.     % assign values to a temporary struct
  39.     public_struct.Size = this.mSize;
  40.     public_struct.ColorRgb = ...
  41.         subsref(this, substruct('.', 'ColorRgb'));
  42.     % use eval to assign temp struct into display_name variable
  43.     eval([display_name ' = public_struct;']);
  44.     % use eval to call display on the display_name structure
  45.     eval(['display(' display_name ');']);
  46. else  % array case
  47.     % use eval to assign this into display_name variable
  48.     eval([display_name ' = this;']);
  49.     % use eval to call builtin display for size info
  50.     eval(['builtin(''display'', ' display_name ');']);
  51.     % still need to display variable names explicitly
  52.     disp('    with public member variables:');
  53.     disp('        Size');
  54.     disp('        ColorRgb');
  55.     if strcmp(get(0, 'FormatSpacing'), 'loose')
  56.         disp(' ');
  57.     end
  58. end

  59. % --------------------------
  60. function developer_view(this, display_name)
  61. disp('-----  Public Member Variables  -----');
  62. standard_view(this, display_name);
  63. disp('.....  Private Member Variables  .....');
  64. full_display(this, display_name, true);
复制代码

使用道具

板凳
Lisrelchen 发表于 2016-3-21 06:47:23 |只看作者 |坛友微信交流群
  1. function this = mtimes(lhs, rhs)
  2. % A Comprehensive Guide to Object Oriented Programming in MATLAB
  3. %   Chapter 5 example mtimes
  4. %   (c) 2004 Andy Register

  5. % one input must be cShape type, which one
  6. if isa(lhs, 'cShape')
  7.     this = lhs;
  8.     scale = rhs;
  9. else
  10.     this = rhs;
  11.     scale = lhs;
  12. end

  13. switch length(scale(:))
  14.     case 1
  15.         scale = [scale; scale];
  16.     case 2
  17.         scale = scale(:);
  18.     otherwise
  19.         error('??? Error using ==> mtimes');
  20. end

  21. this.mSize = this.mSize .* scale;
  22. this.mScale = this.mScale .* scale;
复制代码

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-22 13:28