matlab建模电风扇,【文章】仿真设计作品--调速电风扇

icon1.gif 【文章】仿真设计作品--调速电风扇

clear

speed = 100;

t = 0;

Y_a = 4;Y_b = 4;Y_c = 4;

y0 = figure;

axis equal;axis off

axis([-6 6 -10 6])

title('可调速电风扇','fontsize',15);

grid off;

[x1,y1,z1]=sphere(30);

x=5*x1;y=5*y1;z=5*z1;

shading interp;

hold on;

mesh(x,y,z),colormap(hot);

hold on;

hidden off;

hold on;

fill([-3,-1,1,3],[-8.5,-5,-5,-8.5],[0.5,0.5,0.5]);

text(-0.6,-6,'慧儿 ','color','k');

text(-1.2,-7,'02043124 ','color','k');

hold on

ax = Y_a * cos(2 * pi * t);ay = Y_a * sin(2 * pi * t);

bx = Y_b * cos(2 * pi * t - 2 * pi/3);by = Y_b * sin(2 * pi * t - 2 * pi/3);

cx = Y_c * cos(2 * pi * t + 2 * pi/3);cy = Y_c * sin(2 * pi * t + 2 * pi/3);

y_line_a = line([0 ax],[0 ay],'EraseMode','xor','Color','r','linestyle','-','linewidth',20);

y_line_b = line([0 bx],[0 by],'EraseMode','xor','Color','b','linestyle','-','linewidth',20);

y_line_c = line([0 cx],[0 cy],'EraseMode','xor','Color','g','linestyle','-','linewidth',20);

a(2,:) = linspace(2,6,2 * speed);

b = a;

c = a;

a(1,1) = ay;

b(1,1) = by;

c(1,1) = cy;

k=1;

b1=uicontrol('parent',y0,...

'units','points',...

'tag','b2',...

'style','pushbutton',...

'string','停止',...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[280 10 50 20],...

'callback','k=0;');

b2=uicontrol('parent',y0,...

'units','points',...

'tag','b3',...

'style','pushbutton',...

'string','关闭',...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[350 10 50 20],...

'callback',[...

'k=1;,',...

'close']);

s1=uicontrol('parent',y0,...

'units','points',...

'tag','s1',...

'style','slider',...

'value',1*speed,...

'max',100,...

'min',30,...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[30 10 190 20],...

'callback',[...

'm=get(gcbo,''value'');,',...

'speed=m/1;']);

t1=uicontrol('parent',y0,...

'units','points',...

'tag','t1',...

'style','text',...

'fontsize',15,...

'string','风速 请点击滑动条空白处',...

'backgroundcolor',[0.75 0.75 0.75],...

'position',[30 30 190 20]);

while 1

if k==0

break

end

t = t + 1/speed;

ax = Y_a * cos(2 * pi * t);ay = Y_a * sin(2 * pi * t);

bx = Y_b * cos(2 * pi * t - 2 * pi/3);by = Y_b * sin(2 * pi * t - 2 * pi/3);

cx = Y_c * cos(2 * pi * t + 2 * pi/3);cy = Y_c * sin(2 * pi * t + 2 * pi/3);

drawnow;

set(y_line_a,'XData',[0 ax],'YData',[0 ay]);

set(y_line_b,'XData',[0 bx],'YData',[0 by]);

set(y_line_c,'XData',[0 cx],'YData',[0 cy]);

for i = 1 : 2 * speed - 1;

a(1,2 * speed + 1 - i) = a(1,2 * speed - i);

b(1,2 * speed + 1 - i) = b(1,2 * speed - i);

c(1,2 * speed + 1 - i) = c(1,2 * speed - i);

end

end

end

2005年10月31日发表在《麓瑜园》

(注:本文转自转自《麓瑜园》,版权归原作者所有!在此仅作交流讨论之用,如需转载请注明原作者!)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一个不错的Matlab的gui界面设计实例 精美日历 function CalendarTable; % calendar 日历 % Example: % CalendarTable; S=datestr(now); [y,m,d]=datevec(S); % d is day % m is month % y is year DD={'Sun','Mon','Tue','Wed','Thu','Fri','Sat'}; close all figure; for k=1:7; uicontrol(gcf,'style','text',... 'unit','normalized','position',[0.02+k*0.1,0.55,0.08,0.06],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor','b',... 'String',DD(k),'fontsize',16,'fontname','times new roman'); end h=1; ss='b'; qq=eomday(y,m); for k=1:qq; n=datenum(y,m,k); [da,w] = weekday(n); if k==d; ss='r'; end uicontrol(gcf,'style','push',... 'unit','normalized','position',[0.02+da*0.1,0.55-h*0.08,0.08,0.06],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor',ss,... 'String',num2str(k)); ss='b'; if da==7; h=h+1; end end uicontrol(gcf,'style','push',... 'unit','normalized','position',[0.6,0.66,0.12,0.08],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor',ss,... 'String','clock','fontsize',18,'fontname','times new roman'); Tq=uicontrol(gcf,'style','push',... 'unit','normalized','position',[0.74,0.66,0.17,0.08],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor',[0.1,0.9,0.9],... 'fontsize',18,'fontname','times new roman'); sq='The calendar'; uicontrol(gcf,'style','push',... 'unit','normalized','position',[0.14,0.86,0.37,0.08],... 'BackgroundColor',0.6*[1,1,1],'ForegroundColor',[0.1,0.9,0.9],... 'fontsize',18,'fontname','times new roman','string',sq); try while 1 set(Tq,'String',datestr(now,13)); pause(1); end end

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值