Xem mẫu

  1. ÑOÀ AÙN TOÁT NGHIEÄP Chương 13: Maõ nguoàn a) Demo function demo() t=(1:2:15)'*pi/8; x=sin(t); y=cos(t); fill(x,y,'r'); axis equal; text(0,0,'CHOÁNG SEÙT','color',[1 1 1],... 'fontname','Vni- times','fontsize',40,... 'HorizontalAlignment','center'); b) Giao dieän: *Tao cac giao dien pw=get(h1_Epw,'string'); if strcmp(pw,'anh') set(h1_Title1,'visible','off'); set(h1_CT,'visible','off'); set(h1_HCG,'visible','off'); set(h1_TPW,'visible','off'); set(h1_Epw,'visible','off'); set(h1_THE,'visible','on'); set(h1_Frame1,'visible','on'); set(h1_Frame2,'visible','on'); set(h1_Frame3,'visible','on'); set(h1_Frame4,'visible','on'); set(h1_Tlwh,'visible','on'); set(h1_TL,'visible','on'); set(h1_TW,'visible','on'); set(h1_TH,'visible','on'); set(h1_Ngmax,'visible','on'); TRANG 49
  2. ÑOÀ AÙN TOÁT NGHIEÄP set(h1_EL,'visible','on'); set(h1_EW,'visible','on'); set(h1_EH,'visible','on'); set(h1_ENgmax,'visible','on'); set(h1_TC,'visible','on'); set(h1_TC1,'visible','on'); set(h1_TC2,'visible','on'); set(h1_TC3,'visible','on'); set(h1_TC4,'visible','on'); set(h1_TC5,'visible','on'); set(h1_PC1,'visible','on'); set(h1_PC2,'visible','on'); set(h1_PC3,'visible','on'); set(h1_PC4,'visible','on'); set(h1_PC5,'visible','on'); set(h1_TKQ,'visible','on'); set(h1_TNd,'visible','on'); set(h1_TNc,'visible','on'); set(h1_TE,'visible','on'); set(h1_ENd,'visible','on'); set(h1_ENc,'visible','on'); set(h1_EE,'visible','on'); set(h1_BAction,'visible','on'); demo; end c) spkt load SPKT h0 = figure('Units','points', ... 'Color',[0 0 0], ... 'Colormap',mat0, ... 'FileName','SPKT', ... 'MenuBar','none', ... TRANG 50
  3. ÑOÀ AÙN TOÁT NGHIEÄP 'Name','HE CHUYEN GIA CHONG SET', ... 'NumberTitle','off', ... 'PaperPosition',[18 180 576 432], ... 'PaperUnits','points', ... 'Position',[0 21 480 324.75], ... 'Tag','Fig1', ... 'ToolBar','none',... 'DefaultaxesColor','none', ... 'DefaultaxesXColor',[1 0 1], ... 'DefaultaxesYColor',[1 0 1], ... 'DefaultaxesZColor',[1 0 1]); h1_axes = axes('Parent',h0, ... 'Units','pixels', ... 'CameraUpVector',[0 1 0], ... 'Color',[0 0 0], ... 'ColorOrder',mat1, ... 'Position',[232 45 386 314], ... 'Tag','Axes1', ... 'visible','off',... 'XColor',[1 0 1], ... 'YColor',[1 0 1], ... 'ZColor',[1 0 1]); h1_Title1 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0 0 0], ... 'FontName','Vni-times', ... 'FontSize',20, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[37.5 242.25 405.75 59.25], ... 'String','TRÖÔØNG ÑAÏI HOÏC SÖ PHAÏM KYÕ THUAÄT KHOA ÑIEÄN ÑIEÄN TÖÛ', ... TRANG 51
  4. ÑOÀ AÙN TOÁT NGHIEÄP 'Style','text', ... 'Tag','StaticText1'); h1_CT = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0 0 0], ... 'FontName','Vni-times', ... 'FontSize',15, ... 'ForegroundColor',[0 1 0], ... 'ListboxTop',0, ... 'Position',[43.5 198 96.75 19.5], ... 'String','Chöông trình', ... 'Style','text', ... 'Tag','StaticText2'); h1_HCG = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0 0 0], ... 'FontName','Vni-times', ... 'FontSize',30, ... 'ForegroundColor',[0 0 1], ... 'ListboxTop',0, ... 'Position',[57.75 129 395.25 37.5], ... 'String','XAÙC ÑÒNH MÖÙC BAÛO VEÄ CHOÁNG SEÙT', ... 'Style','text', ... 'Tag','StaticText3'); h1_TPW = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0 0 0], ... 'FontName','Vni-times', ... 'FontSize',15, ... 'ForegroundColor',[0 1 0], ... 'ListboxTop',0, ... 'Position',[124.5 54.75 102 21.75], ... TRANG 52
  5. ÑOÀ AÙN TOÁT NGHIEÄP 'String','Nhaäp maät khaåu', ... 'Style','text', ... 'Tag','StaticText4'); h1_Epw = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[233.25 56.25 84.75 18], ... 'Style','edit', ... 'callback','giaodien',... 'Tag','EditText1'); h1_THE = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0 1 0], ... 'FontName','Vni-times', ... 'FontSize',18, ... 'ForegroundColor',[0.501960784313725 0 0.501960784313725], ... 'ListboxTop',0, ... 'Position',[162.75 287.25 306.75 25.5], ... 'String','XAÙC ÑÒNH MÖÙC BAÛO VEÄ', ... 'visible','off',... 'Style','text', ... 'Tag','StaticText5'); h1_Frame1 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.501960784313725], ... 'ListboxTop',0, ... 'Position',[3 7.5 150 315.75], ... 'Style','frame', ... 'visible','off',... 'Tag','Frame1'); TRANG 53
  6. ÑOÀ AÙN TOÁT NGHIEÄP h1_Frame2 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'ListboxTop',0, ... 'Position',[9 222.75 138.75 79.5], ... 'Style','frame', ... 'visible','off',... 'Tag','Frame2'); h1_Tlwh = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.501960784313725], ... 'FontName','Vni-times', ... 'FontSize',11, ... 'ForegroundColor',[0 1 0.250980392156863], ... 'ListboxTop',0, ... 'Position',[12.75 304.5 129 16.5], ... 'String','Nhaäp caùc thoâng soá', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText6'); h1_TL = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[10.5 288 64.5 12], ... 'String','Thoâng soá L', ... 'Style','text', ... TRANG 54
  7. ÑOÀ AÙN TOÁT NGHIEÄP 'visible','off',... 'Tag','StaticText7'); h1_TW = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[10.5 269.25 64.5 12], ... 'String','Thoâng soá W', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText7'); h1_TH = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[10.5 249 64.5 12], ... 'String','Thoâng soá H', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText7'); h1_Ngmax = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... TRANG 55
  8. ÑOÀ AÙN TOÁT NGHIEÄP 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[11.25 226.5 67.5 15.75], ... 'String','Thoâng soá Ngm', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText7'); h1_EL = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[81.75 285.75 63.75 15], ... 'Style','edit', ... 'string','0',... 'visible','off',... 'Tag','EditText2'); h1_EW = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[81 267 63.75 15], ... 'Style','edit', ... 'string','0',... 'visible','off',... 'Tag','EditText2'); h1_EH = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[81 247.5 63.75 15], ... 'Style','edit', ... 'string','0',... 'visible','off',... TRANG 56
  9. ÑOÀ AÙN TOÁT NGHIEÄP 'Tag','EditText2'); h1_ENgmax = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[81 227.25 63.75 15], ... 'Style','edit', ... 'visible','off',... 'string','0',... 'Tag','EditText2'); h1_TC = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.501960784313725], ... 'FontName','Vni-times', ... 'FontSize',11, ... 'ForegroundColor',[0 1 0], ... 'ListboxTop',0, ... 'Position',[21 202.5 112.5 16.5], ... 'String','Choïn caùc thoâng soá C', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText8'); h1_Frame3 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'ListboxTop',0, ... 'Position',[8.25 110.25 138.75 90.75], ... 'Style','frame', ... 'visible','off',... 'Tag','Frame3'); h1_TC1 = uicontrol('Parent',h0, ... TRANG 57
  10. ÑOÀ AÙN TOÁT NGHIEÄP 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[10.5 183.75 60.75 13.5], ... 'String','Choïn C1', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText9'); h1_TC2 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[11.25 165.75 60.75 14.25], ... 'String','Choïn C2', ... 'visible','off',... 'Style','text', ... 'Tag','StaticText9'); h1_TC3 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... TRANG 58
  11. ÑOÀ AÙN TOÁT NGHIEÄP 'Position',[11.25 149.25 60.75 12.75], ... 'String','Choïn C3', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText9'); h1_TC4 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[10.5 132 60.75 13.5], ... 'String','Choïn C4', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText9'); h1_TC5 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.250980392156863], ... 'FontName','Vni-times', ... 'FontSize',10, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[10.5 114.75 60.75 14.25], ... 'String','Choïn C5', ... 'Style','text', ... 'visible','off',... 'Tag','StaticText9'); h1_PC1 = uicontrol('Parent',h0, ... TRANG 59
  12. ÑOÀ AÙN TOÁT NGHIEÄP 'Units','points', ... 'ListboxTop',0, ... 'Position',[81 184.5 63.75 15.75], ... 'String','0.25|0.5|1.0|1.0', ... 'Style','popupmenu', ... 'Tag','PopupMenu1', ... 'visible','off',... 'Value',1); h1_PC2 = uicontrol('Parent',h0, ... 'Units','points', ... 'ListboxTop',0, ... 'Position',[81 166.5 63.75 15.75], ... 'String','0.5|1.0|2.0', ... 'Style','popupmenu', ... 'Tag','PopupMenu1', ... 'visible','off',... 'Value',1); h1_PC3 = uicontrol('Parent',h0, ... 'Units','points', ... 'ListboxTop',0, ... 'Position',[80.25 148.5 63.75 15.75], ... 'String','0.5|1.0|2.0|3.0', ... 'Style','popupmenu', ... 'Tag','PopupMenu1', ... 'visible','off',... 'Value',1); h1_PC4 = uicontrol('Parent',h0, ... 'Units','points', ... 'ListboxTop',0, ... 'Position',[80.25 130.5 63.75 15.75], ... 'String','0.5|1.0|3.0', ... TRANG 60
  13. ÑOÀ AÙN TOÁT NGHIEÄP 'Style','popupmenu', ... 'Tag','PopupMenu1', ... 'visible','off',... 'Value',1); h1_PC5 = uicontrol('Parent',h0, ... 'Units','points', ... 'ListboxTop',0, ... 'Position',[80.25 112.5 63.75 15.75], ... 'String','1.0|5.0|10.0', ... 'Style','popupmenu', ... 'Tag','PopupMenu1', ... 'visible','off',... 'Value',1); h1_TKQ = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.501960784313725 0.501960784313725 0.501960784313725], ... 'FontName','Vni-times', ... 'FontSize',11, ... 'ForegroundColor',[0 1 0], ... 'ListboxTop',0, ... 'Position',[37.5 96 73.5 13.5], ... 'String','Caùc keát quaû', ... 'visible','off',... 'Style','text', ... 'Tag','StaticText10'); h1_Frame4 = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 0], ... 'ListboxTop',0, ... 'Position',[8.25 11.25 138.75 81.75], ... 'Style','frame', ... TRANG 61
  14. ÑOÀ AÙN TOÁT NGHIEÄP 'visible','off',... 'Tag','Frame4'); h1_TNd = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 0], ... 'ForegroundColor',[1 0 0.501960784313725], ... 'ListboxTop',0, ... 'Position',[14.25 75 53.25 12.75], ... 'String','Nd :', ... 'visible','off',... 'Style','text', ... 'Tag','StaticText11'); h1_TNc = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 0], ... 'ForegroundColor',[1 0 0.501960784313725], ... 'ListboxTop',0, ... 'Position',[13.5 56.25 53.25 12.75], ... 'String','Nc :', ... 'visible','off',... 'Style','text', ... 'Tag','StaticText11'); h1_ENd = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[80.25 72.75 64.5 15], ... 'Style','edit', ... 'visible','off',... 'string','0',... 'Tag','EditText3'); TRANG 62
  15. ÑOÀ AÙN TOÁT NGHIEÄP h1_ENc = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[81 54.75 64.5 15], ... 'Style','edit', ... 'visible','off',... 'string','0',... 'Tag','EditText3'); h1_TE = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 0], ... 'ForegroundColor',[1 0 0.501960784313725], ... 'ListboxTop',0, ... 'Position',[13.5 36 53.25 12.75], ... 'String','E :', ... 'visible','off',... 'Style','text', ... 'Tag','StaticText11'); h1_EE = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[1 1 1], ... 'ListboxTop',0, ... 'Position',[80.25 36.75 64.5 15], ... 'Style','edit', ... 'visible','off',... 'string','0',... 'Tag','EditText3'); h1_BAction = uicontrol('Parent',h0, ... 'Units','points', ... 'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ... TRANG 63
  16. ÑOÀ AÙN TOÁT NGHIEÄP 'FontName','Vni-times', ... 'FontSize',15, ... 'ForegroundColor',[1 0 0], ... 'ListboxTop',0, ... 'Position',[9 13.5 137.25 21], ... 'String','Tính toaùn', ... 'callback','TinhToan,set(h1_axes,''visible '',''on'')',... 'visible','off',... 'Tag','Pushbutton1'); d) tính toan %Nhap cac thong so tinh toan %Tinh Nd L=get(h1_EL,'string'); L=str2num(L); W=get(h1_EW,'string'); W=str2num(W); H=get(h1_EH,'string'); H=str2num(H); Ngmax=get(h1_ENgmax,'string'); Ngmax=str2num(Ngmax); Ac=L*W+6*H*(L+W)+9*pi*H^2; %Chãn C1 choiceC1=get(h1_PC1,'value'); if choiceC1==1,C1=0.25 ; elseif choiceC1==2,C1=0.5 ; elseif choiceC1==3,C1=1.0; elseif choiceC1==4,C1=3.0 ; end Nd=Ngmax*Ac*C1*10^(-6); set(h1_ENd,'string',Nd); TRANG 64
  17. ÑOÀ AÙN TOÁT NGHIEÄP %TÛnh Nc %Chãn C2 choiceC2=get(h1_PC2,'value'); if choiceC2==1,C2=0.5 ; elseif choiceC2==2,C2=1.0; elseif choiceC2==3,C2=2.0 ; end %Chãn C3 choiceC3=get(h1_PC3,'value'); if choiceC3==1,C3=0.5 ; elseif choiceC3==2,C3=1.0; elseif choiceC3==3,C3=2.0 ; elseif choiceC3==4,C3=3.0 ; end %Chãn C4 choiceC4=get(h1_PC4,'value'); if choiceC4==1,C4=0.5 ; elseif choiceC4==2,C4=1.0; elseif choiceC4==3,C4=3.0 ; end %Chãn C5 choiceC5=get(h1_PC5,'value'); if choiceC5==1,C5=1.0 ; elseif choiceC5==2,C5=5.0; elseif choiceC5==3,C5=10.0 ; end C=C2*C3*C4*C5; Nc=5.5/C; set(h1_ENc,'string',Nc); if Nd
  18. ÑOÀ AÙN TOÁT NGHIEÄP else E=1-Nc/Nd; set(h1_EE,'string',E); if (E>0.98),set(h1_THE,'FontName','Vni- times', ... 'FontSize',15,'string','BAÛO VEÄ CAÁP 1 + BOÅ SUNG'); elseif (E>=0.95)&(E=0.8)&(E0)&(E
  19. ÑOÀ AÙN TOÁT NGHIEÄP x1=[0 L];y1=[2*H+2 2*H+2];plot(x1,y1,'-- '); text(L/2,2*H-1,' \downarrow L','fontsize',8,'color','r'); x2=[L L];y2=[2*H+2 H+2];plot(x2,y2,'--'); x3=[L 0];y3=[H+2 H+2];plot(x3,y3,'--'); %w Lª chiÒu rèng x4=[0 W];y4=[2*H+2 2.25*H+2];plot(x4,y4,'- -'); x5=[W L+W];y5=[2.25*H+2 2.25*H+2];plot(x5,y5,'--'); x6=[L+W L];y6=[2.25*H+2 2*H+2];plot(x6,y6,'--'); text(L+1,2*H+1,'\uparrow W','fontsize',8,'color','r'); x7=[L+W L+W];y7=[2.25*H+2 1.25*H+2];plot(x7,y7,'--'); x8=[L+W L];y8=[1.25*H+2 H+2];plot(x8,y8,'- -'); title('Kích thöôùc toaø nhaø','Fontname','Vni-times',... 'fontsize',15,'color','y'); %axis off hold off global h subplot(2,1.65,3.3); h=rectangle('Position',[0,0,(6*H)+W,(6*H)+ L],... 'Curvature',[0.8,0.4],... 'LineWidth',2,'FaceColor','r','EdgeColor', 'r'); title('Dieän tích töông ñöông AC','Fontname','Vni-times',... 'fontsize',15,'color','y'); TRANG 67
  20. ÑOÀ AÙN TOÁT NGHIEÄP TRANG 68