A list,

1 Design Background We design this adjustable speed fan from daily life and their own interest. Changzhou is a typical city in the South of the Yangtze River. Compared with changzhou, we have all experienced the extreme heat, especially in school days, it is unbearable. Based on this, we came up with this adjustable speed fan. 2 General idea first make a frame of the fan, draw three blades, and then change the coordinates of the fan blades through the change of time, so that the fan blades have the effect of moving, and the fan turns. Make a slider to realize the variable speed function, so that is a variable speed fan model. Finally, add a timing feature, and you’re almost done.

Ii. Source code

clear; clc; global speed; global k; global h01; global m01; T_1 =clock; % returns a six-element decimal number vector containing the current date and time [Year Month day hour minute seconds]; h0=t_1(4); % set time m0=t_1(5);
    speed = 100;
    t = 0;
    Y_a = 4; Y_b =4; Y_c =4;
    y0 = figure;
    axis equal;axis off
    set(gcf,'name'.'Variable speed fan'); % Named image name: variable speed fanset(gcf,'NumberTitle'.'off'); % does not display the image numberset(gcf,'MenuBar'.'none'); % do not display menu barset(gcf,'doublebuffer'.'on'% Enable double cache to eliminate flicker phenomenon'units'.'normalized'); % gets the handle to the axis. uistack(beijing,'bottom'); % resets the position of the object, where:'up'.'down'.'top' or 'bottom'
    II=imread('bg.jpg'); %II=imread('shiyan0.bmp'); Note the path problem, change the file name here to change the background image. image(II); % Show picturesset (gca,'position'[0.0.1.1]); % Set the axis distance from the artboard (figure window) margin. [0.0.1.1] are left boundary, lower boundary, width and height of AXES in the figure, and the minimum is0And the maximum is1The left boundary and the lower boundary are0, the upper boundary, and the right boundary is1), this will fill the window.set(beijing,'handlevisibility'.'off'.'visible'.'off');
    axis([- 6 6 - 10 6])
    title('Adjustable speed fan'.'fontsize'.15); %%% set drawing name grid off; %%% closes plotting grid point k=1; % % % % % % % % % % % % % % % % Settings button % % % % % % % % % % % % % % % % % % % % % % % % % % % % % set confirmation button % % % % % % % % % % % % % in the plot of the position (a b c d) determine the location of the graphics area, [a b] is the coordinates of the lower left point of the plot area. C, d are the width and height of the drawing area. [350 10 50 20]

uicontrol(gcf,'style'.'Pushbutton'.'string'.'confirm'.'Position'[420.50.50.20].'backgroundcolor'[0.75 0.75 0.75].'Callback'.'h01=str2num(get(D1,''string'')); m01=str2num(get(D2,''string'')); '); %%%%%% Set the cancel button %%%%%%% uicontrol(GCF,'style'.'Pushbutton'.'string'.'cancel'.'Position'[475.50.50.20].'backgroundcolor'[0.75 0.75 0.75].'Callback'.'h01=0; m01=01; '); %%%%%%%%%% Set the time edit box %%%%%% D1=uicontrol(GCF,'style'.'Edit'.'string'.'00'.'Position'[320.50.50.20].'backgroundcolor'[0.75 0.75 0.75]);

D2=uicontrol(gcf,'style'.'Edit'.'string'.'00'.'Position'[360.50.50.20].'backgroundcolor'[0.75 0.75 0.75]); % Settings: static text box uicontrol(GCF,'style'.'text'.'string'.':'.'Position'[360.50.10.20].'backgroundcolor'[0.75 0.75 0.75]); %%%%%% Set the start button %%%%%%% b0=uicontrol('parent',y0,'units'.'points'.'tag'.'b1'.'style'.'pushbutton'.'string'.'开始'.'backgroundcolor'[0.75 0.75 0.75].'position'[220 10 50 20].'callback'.'k=1; '); %%%%%% Set the start button %%%%%%% b1=uicontrol('parent',y0,'units'.'points'.'tag'.'b2'.'style'.'pushbutton'.'string'.'stop'.'backgroundcolor'[0.75 0.75 0.75].'position'[280 10 50 20],...
        'callback'.'k=0; '); %%%%%% Set shutdown key %%%%%%% b2=uicontrol('parent',y0,'units'.'points'.'tag'.'b3'.'style'.'pushbutton'.'string'.'off'.'backgroundcolor'[0.75 0.75 0.75].'position'[350 10 50 20],...
        'callback'['k=1; , '.'close']); %%%close: close the program, but do not exit the MATLAB environment, can be changed to quit if necessary,exit%%%%%% set the wind speed adjustment slider %%%%%%% % s11=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; '.'yunxing(k,speed)']); % gCBO is being executed"Correction"Object handle s11=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; ']);
 
%     speed = get(s11,'Value')
%     speed1 = get(s11,'Value'%%%%%% Static text box %%%%%%% t1=uicontrol('parent',y0,'units'.'points'.'tag'.'t1'.'style'.'text'.'fontsize'.15.'string'.'High -- wind speed -- low'.'backgroundcolor'[0.75 0.75 0.75].'position'[30 30 190 20]);


    [x1,y1,z1]=sphere(30); % produces the sphere coordinate x=5*x1; y=5*y1; z=5*z1; shading interp; %%shading is used to deal with color effects, which can be divided into the following three kinds: shading interp interpolates colors on a flat basis to make smooth color transition; The default mode for no shading is shading. The default mode for no shading is shading. hold on; mesh(x,y,z),colormap(hot); % Paint fan frame hold on;function yunxing(k,speed)
  k=1;
h01=0; m01=01;
 t_1=clock;   
    h0=t_1(4); % set time m0=t_1(5);    
    t = 0;
    Y_a = 4; Y_b =4; Y_c =4;
 [x1,y1,z1]=sphere(30); % produces the sphere coordinate x=5*x1; y=5*y1; z=5*z1; shading interp; %%shading is used to deal with color effects, which can be divided into the following three kinds: shading interp interpolates colors on a flat basis to make smooth color transition; The default mode for no shading is shading. The default mode for no shading is shading. hold on; mesh(x,y,z),colormap(hot); % Paint fan frame hold on; hidden off; % % % of mesh3In a dimension diagram, hidden off is the part of the graph behind that is obscured by the previous graph (hidden off). hold on; fill([- 3.- 1.1.3], [8.5.- 5.- 5.8.5], [0.5.0.5.0.5]); % Draw a polygon text(0.6.- 6.'fun'.'color'.'k');
    text(1.2.7 -.'Just for fun'.'color'.'k');
    hold on
    ax = Y_a * cos(2* pi * t); ay = Y_a *sin(2* pi * t); % Calculate the abscissa and ordinate of the initial three blades 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'.The '-'.'linewidth'.20); % Draw three leaves by drawing a widened line y_line_b = line([0 bx],[0 by],'EraseMode'.'xor'.'Color'.'b'.'linestyle'.The '-'.'linewidth'.20);
    y_line_c = line([0 cx],[0 cy],'EraseMode'.'xor'.'Color'.'g'.'linestyle'.The '-'.'linewidth'.20);
    a(2,:) = linspace(2.6.2* speed); %linspace(X1, X2, N) is a row vector uniformly generating an N point between X1 and X2; b = a; c = a; a(1.1) = ay;
    b(1.1) = by;
    c(1.1) = cy;
  
while k

        if k==0pause(); %%% Stop key response, pause () : Press any key to continue by default. elseif m0==m01&h0==h01 pause(); %%% Timing function response %k=0;
        end
%            speed1 = get(s11,'Value'); % gets the value of the slider as speedCopy the code

3. Operation results

Fourth, note

Version: 2014 a