程序代码分析?

2026-02-21 12:43:11

1、h = gobjects(1,500);

通过这个函数可以生成的数组矩阵。共有1行,500列。

程序代码分析?

2、p = zeros(500,3);

生成500行,3列这样的一个0矩阵。

程序代码分析?

3、for ix = 1:500

   h(ix) = text(ix/500,ix/500,num2str(ix));

end

drawnow

ix,起始点为1,终点为500,步进默认为1。

for,循环。

程序代码分析?

程序代码分析?

4、% Get and save property values

for ix=1:500

   pos = get(h(ix),'Position');

   ext = get(h(ix),'Extent');

   p(ix,:) = [pos(1)+(ext(3)+ext(1)), ...

              pos(2)+ext(2)+ext(4),0];

end

%v=get(h,propertyName)返回特定属性propertyName的值。在属性名周围使用单引号,例如get(h,'Color')。如果不指定输出参数,则MATLAB将在屏幕上显示信息。

程序代码分析?

5、% Set the property values and 

% call a drawnow after the loop

for ix=1:500

   set(h(ix),'Position',p(ix,:));

end

drawnow

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢