Bai 3 thuc hanh thiet ke mo hinh hoa mo phong do tin cay cua thiet bi dien tu

29 446 1
Bai 3 thuc hanh thiet ke mo hinh hoa mo phong do tin cay cua thiet bi dien tu

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Bài XÂY DỰNG MÔ HÌNH HÓA MÔ PHỎNG ĐỘ TIN CẬY CỦA THIẾT BỊ ĐIỆN TỬ TRÊN CÔNG CỤ GUIDE CỦA PHẦN MỀM MATLAB I Mục đích - Giúp sinh viên hiểu phương pháp xây dựng mô hình hóa mô hệ thống vật lý - Thu thập phân tích bảng liệu hệ thống - Đánh giá kết mô phỏng, so sánh độ tương đồng kết mô mô hình với tính chất đối tượng thực - Đưa kết luận phương án điều chỉnh cho đối tượng thực dựa kết mô sau phân tích chúng II Yêu cầu thực hành - Máy vi tính cài đặt sẵn phần mềm Matlab với đầy đủ ứng dụng Math Work cung cấp - Yêu cầu sinh viên trang bị phần lý thuyết môn Tin học chuyên ngành, hết chương Mô hệ ngẫu nhiên môn Mô hình hóa - Tuân thủ nội quy, quy định thực hành phòng thí nghiệm III Nội dung thực hành 3.1 Bài toán yêu cầu Dùng phương pháp mô để tính toán độ tin cậy thiết bị, biết cường độ hỏng hóc λ = 10-3 (l/h) Hãy vẽ đường cong biểu diễn độ tin cậy P(t) lý thuyết P(t) mô số lần thực nghiệm S = 300, S = 1000, S = 3000; 3.2 Các bước tiến hành Do cường độ hỏng hóc thiết bị λ(lan/gio)=const nên dòng hỏng hóc dòng tối giản Như khoảng cách lần hỏng hóc ti tuân theo luật phân bố mũ Gọi T thời gian khảo sát Thiết bị coi làm việc tin cậy khoảng cách lần hỏng hóc lớn thời gian khảo sát ti>T (Trong khoảng thời gian khảo sát thiết bị không bị hỏng) Như độ tin cậy P(ti>T) Bước Thuật toán mô phỏng: (1) Lấy số ngẫu nhiên Ui ~ U(0,1) Vậy ti = - ln(Ui/ λ) (2) So sánh ti với T: Nếu ti > T thiết bị làm việc tin cậy Nếu ti < T thiết bị làm việc không tin cậy (3) Thực N thử nghiệm Độ tin cậy thiết bị đánh sau: P(ti>T) = Số thiết bị làm việc tin cậy/Số thiết bị thử nghiệm (4) Độ tin cậy lý thuyết P*(t) = expo(-λT) (5) So sánh P(t) P*(t) Bước Xây dựng giao diện mô hệ thống điều khiển tự động (1) Khởi tạo guide phần mềm Matlab (2) Thiết lập bảng điều khiển giao diện - Chọn công cụ Panel - Thay đổi tên cho Panel cách kích đúp vào Panel - thay tên phần Title từ tên - Panel sang tên “Bang dieu khien” - Chọn công cụ Push Button để khai báo nút khảo sát hệ thống Đổi tên PushButton String Inspector nút sang tên khảo sát hệ thống + Kết thu + Tương tự ta lấy nút có tên gọi “Thoát khỏi hệ thống” - Chọn công cụ Panel để khai báo bảng nhập giá trị > Độ tin cậy lý thuyết xuất Edit4 > Số thiết bị làm việc tin cậy xuất Edit6 > Sai lệch Edit8 > Độ tin cậy mô xuất Edit5 > Số thiết bị làm việc không tin cậy xuất Edit7 Bước Viết Code cho nút điều khiển (1) Nút thoát khỏi hệ thống Nhấn chuột phải vào Nút “ Thoat khoi he thong” chọn View callBacks/Callback + Ta lập trình sau: hoi=questdlg('Ban muon thoat khoi chuong trinh?', 'THUC SU MUON THOAT?','Yes','No','No'); if strcmp(hoi,'Yes') close if strcmp(hoi,'No') return; end end (2) Nút “Khao sat he thong” Nhấn chuột phải vào Nút “Khao sat he thong” chọn View callBacks/Callback + Ta lập trình: function varargout = Bai3(varargin) % BAI3 MATLAB code for Bai3.fig % BAI3, by itself, creates a new BAI3 or raises the existing % singleton* % % H = BAI3 returns the handle to a new BAI3 or the handle to % the existing singleton* % % BAI3('CALLBACK',hObject,eventData,handles, ) calls the local % function named CALLBACK in BAI3.M with the given input arguments % % BAI3('Property','Value', ) creates a new BAI3 or raises the % existing singleton* Starting from the left, property value pairs are % applied to the GUI before Bai3_OpeningFcn gets called An % unrecognized property name or invalid value makes property application % stop All inputs are passed to Bai3_OpeningFcn via varargin % % *See GUI Options on GUIDE's Tools menu Choose "GUI allows only one % instance to run (singleton)" % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help Bai3 % Last Modified by GUIDE v2.5 06-Mar-2013 15:29:22 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, 'gui_Singleton', gui_Singleton, 'gui_OpeningFcn', @Bai3_OpeningFcn, 'gui_OutputFcn', @Bai3_OutputFcn, 'gui_LayoutFcn', [] , 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % - Executes just before Bai3 is made visible function Bai3_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to Bai3 (see VARARGIN) % Choose default command line output for Bai3 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes Bai3 wait for user response (see UIRESUME) % uiwait(handles.figure1); % - Outputs from this function are returned to the command line function varargout = Bai3_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % - Executes on button press in pushbutton1 function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Ch??ng trình ví du 3.1 v? v? ?? th? c?a h? th?ng ?i?u khi?n t? ??ng disp('MO PHONG HE THONG DANH GIA DO TIN CAY CUA THIET BI DIEN TU - THM') clc; % Khai bao bien syms N lamda T N = get(handles.edit1,'String');% Nhan chuoi ky tu edit1 gán cho N N = str2num(N); %Chuyen gia tri chuoi ký tu sang dang so lamda = get(handles.edit2,'String');% Nh?n chu?i ký t? ? edit2 gán cho k2 lamda = str2num(lamda); %Chuy?n ??i t? chu?i ký t? sang d?ng s? T = get(handles.edit3,'String');% Nh?n chu?i ký t? ? edit3 gán cho t1 T = str2num(T); %Chuy?n ??i t? chu?i ký t? sang d?ng s? sothietbilamviectincay=0; for i = 1:N Ui = rand(1); ti = -(log(Ui)/lamda); if ti>=T sothietbilamviectincay = sothietbilamviectincay+1; end end % Do tin cay mo phong la Pt = (sothietbilamviectincay/N); set(handles.edit5,'String',Pt); % Do tin cay ly thuyet la Plt = exp(-lamda*T); set(handles.edit4,'String',Plt); %So thiet bi lam viec tin cay set(handles.edit6,'String',sothietbilamviectincay); %So thiet bi lam viec khong tin cay sothietbilamvieckhongtincay = N-sothietbilamviectincay; set(handles.edit7,'String',sothietbilamvieckhongtincay); subplot(2,2,2); pie([sothietbilamviectincay sothietbilamvieckhongtincay ],{'So thiet bi lam viec tin cay','So thiet bi lam viec khong tin cay'}) % Sai lech giua ly thuyet va mo phong sailech= (abs(Pt-Plt)/Plt)*100 set(handles.edit8,'String',sailech); % - Executes on button press in pushbutton2 function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) hoi=questdlg('Ban muon thoat khoi chuong trinh?', 'THUC SU MUON THOAT?','Yes','No','No'); if strcmp(hoi,'Yes') close if strcmp(hoi,'No') return; end end function edit6_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double % - Executes during object creation, after setting all properties function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit7_Callback(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit7 as text % str2double(get(hObject,'String')) returns contents of edit7 as a double % - Executes during object creation, after setting all properties function edit7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit8_Callback(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit8 as text % str2double(get(hObject,'String')) returns contents of edit8 as a double % - Executes during object creation, after setting all properties function edit8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double % - Executes during object creation, after setting all properties function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double % - Executes during object creation, after setting all properties function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double % - Executes during object creation, after setting all properties function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double % - Executes during object creation, after setting all properties function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double % - Executes during object creation, after setting all properties function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit11_Callback(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double % - Executes during object creation, after setting all properties function edit11_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % -function Untitled_1_Callback(hObject, eventdata, handles) % hObject handle to Untitled_1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -function Untitled_2_Callback(hObject, eventdata, handles) % hObject handle to Untitled_2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function edit15_Callback(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit8 as text % str2double(get(hObject,'String')) returns contents of edit8 as a double % - Executes during object creation, after setting all properties function edit15_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end [...]... set(handles.edit4,'String',Plt); %So thiet bi lam viec tin cay set(handles.edit6,'String',sothietbilamviectincay); %So thiet bi lam viec khong tin cay sothietbilamvieckhongtincay = N-sothietbilamviectincay; set(handles.edit7,'String',sothietbilamvieckhongtincay); subplot(2,2,2); pie([sothietbilamviectincay sothietbilamvieckhongtincay ],{'So thiet bi lam viec tin cay' ,'So thiet bi lam viec khong tin cay' }) % Sai lech... d?ng s? T = get(handles.edit3,'String');% Nh?n chu?i ký t? ? edit3 gán cho t1 T = str2num(T); %Chuy?n ??i t? chu?i ký t? sang d?ng s? sothietbilamviectincay=0; for i = 1:N Ui = rand(1); ti = -(log(Ui)/lamda); if ti>=T sothietbilamviectincay = sothietbilamviectincay+1; end end % Do tin cay mo phong la Pt = (sothietbilamviectincay/N); set(handles.edit5,'String',Pt); % Do tin cay ly thuyet la Plt = exp(-lamda*T);... chuong trinh?', 'THUC SU MUON THOAT?','Yes','No','No'); if strcmp(hoi,'Yes') close if strcmp(hoi,'No') return; end end (2) Nút “Khao sat he thong” Nhấn chuột phải vào Nút “Khao sat he thong” chọn View callBacks/Callback + Ta lập trình: function varargout = Bai3 (varargin) % BAI3 MATLAB code for Bai3 .fig % BAI3 , by itself, creates a new BAI3 or raises the existing % singleton* % % H = BAI3 returns the handle... defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Ch??ng trình ví du 3. 1 v? v? ?? th? c?a h? th?ng ?i?u khi?n t? ??ng disp( 'MO PHONG HE THONG DANH GIA DO TIN CAY CUA THIET BI DIEN TU - THM') clc; % Khai bao bien syms N lamda T N = get(handles.edit1,'String');% Nhan chuoi ky tu trong edit1 gán cho N N = str2num(N); %Chuyen gia tri chuoi ký tu sang dang... returns the handle to a new BAI3 or the handle to % the existing singleton* % % BAI3 ('CALLBACK',hObject,eventData,handles, ) calls the local % function named CALLBACK in BAI3 .M with the given input arguments % % BAI3 ('Property','Value', ) creates a new BAI3 or raises the % existing singleton* Starting from the left, property value pairs are % applied to the GUI before Bai3 _OpeningFcn gets called An... in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to Bai3 (see VARARGIN) % Choose default command line output for Bai3 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes Bai3 wait for user response (see UIRESUME) % uiwait(handles.figure1); % - Outputs from this function are returned... invalid value makes property application % stop All inputs are passed to Bai3 _OpeningFcn via varargin % % *See GUI Options on GUIDE's Tools menu Choose "GUI allows only one % instance to run (singleton)" % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help Bai3 % Last Modified by GUIDE v2.5 06-Mar-20 13 15:29:22 % Begin initialization code - DO NOT EDIT gui_Singleton... @Bai3 _OpeningFcn, 'gui_OutputFcn', @Bai3 _OutputFcn, 'gui_LayoutFcn', [] , 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % - Executes just before Bai3 is made visible function Bai3 _OpeningFcn(hObject,... get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit3 as text % str2double(get(hObject,'String')) returns... trinh?', 'THUC SU MUON THOAT?','Yes','No','No'); if strcmp(hoi,'Yes') close if strcmp(hoi,'No') return; end end function edit6_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String'))

Ngày đăng: 10/06/2016, 19:08

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan