matlab建模电风扇,关于matlab调速风扇
關(guān)于matlab調(diào)速風(fēng)扇0
代碼如下
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('可調(diào)速電風(fēng)扇','fontsize',15);
grid off;
[x1,y1,z1]=sphere(30); %產(chǎn)生球體坐標(biāo)
x=5*x1;y=5*y1;z=5*z1;
shading interp;
hold on;
mesh(x,y,z),colormap(hot); %畫風(fēng)扇框架
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,'xxxx ','color','k'); %多邊形里的文字
text(-1.2,-7,'xxxxxxx ','color','k'); %多邊形里的文字
hold on
ax = Y_a * cos(2 * pi * t);ay = Y_a * sin(2 * pi * t); %計算初始三個葉片的橫坐標(biāo)和縱坐標(biāo)
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);
k=1;
%b0為開始按鈕
…… ……
while 1 %讓風(fēng)扇轉(zhuǎn)起來的循環(huán)
if k==0
drawnow;
elseif k==1
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]);
end
end
每次停止運行就會出現(xiàn)“??? Error using ==> set
Invalid handle.
Error in ==> D:\matlab\bin\win32\fs.m
On line 94 ==> set(y_line_a,'XData',[0 ax],'YData',[0 ay]);”請問該怎么解決?還有風(fēng)扇底座可以怎么再美化一下嗎?
總結(jié)
以上是生活随笔為你收集整理的matlab建模电风扇,关于matlab调速风扇的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 店铺管理也要996!和996相比,选个靠
 - 下一篇: 电子科技大学计算机专业培养方案,电子科技