1. Trang chủ
  2. » Luận Văn - Báo Cáo

báo cáo matlap

25 10 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 25
Dung lượng 1,14 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

MATLAB là phần mềm cung cấp môi trường tính toán số và lập trình, do công ty MathWorks thiết kế. MATLAB cho phép tính toán số với ma trận, vẽ đồ thị hàm số hay biểu đồ thông tin, thực hiện thuật toán, tạo các giao diện người dùng và liên kết với những chương trình máy tính viết trên nhiều ngôn ngữ lập trình khác.

Trang 1

HỌC VIỆN CÔNG NGHỆ BƯU CHÍNH VIỄN THÔNG

CƠ SỞ TẠI THÀNH PHỐ HỒ CHÍ MINH KHOA KỸ THUẬT ĐIỆN TỬ 2

BÁO CÁO BÀI TẬP LỚN

MÔN: Matlab Và Ứng Dụng

Sinh viên thực hiện:

Phan Hoàng Anh Tuấn N16DCDT120 D16CQDT02-N Nguyễn Anh Thảo N16DCDT056 D16CQDT02-N Đoàn Công Danh N17DCDT014 D17CQDT01-N

Giáo viên hướng dẫn: ThS Trần Quang Thuận

Trang 2

- -Câu 7: Viết một đoạn chương trình (script) đọc giá trị và sai số của điện trở ba

Trang 3

disp('mau nhap vao hien khong có trong bang mau Xin vui long nhap lai:');

Trang 5

• Điện trở 1: 3 vòng màu đỏ-đỏ-nâu có giá trị là 22044 ()

• Điện trở 2: 3 vòng màu nâu-đen-cam có giá trị là 100002000 ()

• Điện trở 3: 3 vòng màu vàng-vàng-đen có giá trị là 448.8()

Trang 6

Nhận xét:

• Chương trình hiển thị kết quả rõ ràng cách tính và sai số

• Chương trình hoạt động tốt và nhanh chóng

function pbtgiai_Callback(hObject, eventdata, handles)

% hObject handle to pbtgiai (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

set(handles.edtx1,'string',num2str(X(1)));

set(handles.edtx2,'string',num2str(X(2)));

set(handles.edtx3,'string',num2str(X(3)));

set(handles.edtx4,'string',num2str(X(4)));

set(handles.edtx5,'string',num2str(X(5)));

set(handles.edtx6,'string',num2str(X(6)));

Trang 7

Kết quả:

Ta có được 1 giao diện người dùng (GUI) giải phương trình nhập các giá trị a, b, c,

d, e, f, g tương ứng theo các bậc Sau đó, nhấn “Giải phương trình” ta sẽ nhận được được 6 nghiệm tương ứng X1, X2, X3, X4, X5, X6.

Trang 8

Với phương trình ta nhận được 6 nghiệm riêng biệt trong đó có: 2 nghiệm thực và

;

4 nghiệm phức , ,

,

Trang 9

Với phương trình ta nhận được 6 nghiệm riêng biệt trong đó có : 2 nghiệm thực và

4 nghiệm phức , ,

, Nhận xét:

• Chương trình hiển thị kết quả rõ ràng cho từng nghiệm của phương trình

• Giao diện đơn giản dễ sử dụng với người dùng

• Chương trình hoạt động tốt và nhanh chóng

Lưu ý:

• Các nghiệm bậc 5, 4, 2, 1 ứng với b, c, e, f luôn luôn nhập số 0

Câu 35: Dùng Simulink mô phỏng phương trình sau:

Quan sát f(t) trên scope và nhận xét dạng sóng.

Trang 10

Ta lấy 3 khối:

1 Khối Clock để cung cấp thời gian t cho phương trình.

2 Khối Fcn để nhập phương trình.

3 Khối Scope để hiện thị kết quả.

Chú ý: trong đây có sử dụng thêm khối dashboard scope ( có thể không sử dụng)

để hiện thị trực tiếp trên một cửa sổ màn hình.

Kết quả:

Ta cài đặt hai đường một là đường màu xanh khi chưa qua khối Fcn và đường màu

đỏ khi qua khối Fcn.

Trang 11

Ta nhận thấy rằng đường màu xanh biểu hiện thời gian tăng dần từ 0 đến 10, đường màu đỏ thì giao động trong biên độ từ -100 đến 100

Lưu ý: khi ta thay đổi biên độ và góc pha của phương trình đã cho thì đồ thị cũng thay đổi

Câu làm thêm: Viết chương trình tạo giao diện người dùng (GUI) thực hiện chức

năng như một máy tính điện tử đơn giản với các phép toán cộng, trừ, nhân, chia, nghịch đảo, căn bậc 2, sin, cos, trong tập số thực.

Code:

function varargout = MayTinhBoTui(varargin)

% MAYTINHBOTUI MATLAB code for MayTinhBoTui.fig

% MAYTINHBOTUI, by itself, creates a new MAYTINHBOTUI

or raises the existing

% singleton*

%

% H = MAYTINHBOTUI returns the handle to a new

MAYTINHBOTUI or the handle to

% the existing singleton*

%

Trang 12

%

MAYTINHBOTUI('CALLBACK',hObject,eventData,handles, ) callsthe local

% function named CALLBACK in MAYTINHBOTUI.M with the given input arguments

%

% MAYTINHBOTUI('Property','Value', ) creates a new MAYTINHBOTUI or raises the

% existing singleton* Starting from the left,

property value pairs are

% applied to the GUI before MayTinhBoTui_OpeningFcn gets called An

% unrecognized property name or invalid value makes property application

% stop All inputs are passed to

MayTinhBoTui_OpeningFcn via varargin

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help

MayTinhBoTui

% Last Modified by GUIDE v2.5 06-Oct-2020 13:21:49

% Begin initialization code - DO NOT EDIT

Trang 13

% End initialization code - DO NOT EDIT

% - Executes just before MayTinhBoTui is made visible.function MayTinhBoTui_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 ofMATLAB

% handles structure with handles and user data (see

% hObject handle to figure

% eventdata reserved - to be defined in a future version ofMATLAB

Trang 14

% handles structure with handles and user data (see

GUIDATA)

% Get default command line output from handles structurevarargout{1} = handles.output;

% - Executes on button press in pbtc

function pbtc_Callback(hObject, eventdata, handles)

% hObject handle to pbtc (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

GUIDATA)

set(handles.kq,'string','0.')

% - Executes on button press in pbtcongtru

function pbtcongtru_Callback(hObject, eventdata, handles)

% hObject handle to pbtcongtru (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbt1

function pbt1_Callback(hObject, eventdata, handles)

% hObject handle to pbt1 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

Trang 15

% - Executes on button press in pbt2.

function pbt2_Callback(hObject, eventdata, handles)

% hObject handle to pbt2 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbt3

function pbt3_Callback(hObject, eventdata, handles)

% hObject handle to pbt3 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtso7

function pbtso7_Callback(hObject, eventdata, handles)

% hObject handle to pbtso7 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

Trang 16

% handles structure with handles and user data (see

% - Executes on button press in pbtso8

function pbtso8_Callback(hObject, eventdata, handles)

% hObject handle to pbtso8 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtso9

function pbtso9_Callback(hObject, eventdata, handles)

% hObject handle to pbtso9 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

Trang 17

jj=0;

% - Executes on button press in pbtchia

function pbtchia_Callback(hObject, eventdata, handles)

% hObject handle to pbtchia (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

GUIDATA)

tmp = get(handles.kq,'string');

tmp = strcat(tmp,'/');

set(handles.kq,'string',tmp)

% - Executes on button press in pbtcan

function pbtcan_Callback(hObject, eventdata, handles)

% hObject handle to pbtcan (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtso4

function pbtso4_Callback(hObject, eventdata, handles)

% hObject handle to pbtso4 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

Trang 18

jj=0;

% - Executes on button press in pbtso5

function pbtso5_Callback(hObject, eventdata, handles)

% hObject handle to pbtso5 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtso6

function pbtso6_Callback(hObject, eventdata, handles)

% hObject handle to pbtso6 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtnhan

function pbtnhan_Callback(hObject, eventdata, handles)

% hObject handle to pbtnhan (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

Trang 19

% handles structure with handles and user data (see

GUIDATA)

tmp = get(handles.kq,'string');

tmp = strcat(tmp,'*');

set(handles.kq,'string',tmp)

% - Executes on button press in pbtsin

function pbtsin_Callback(hObject, eventdata, handles)

% hObject handle to pbtsin (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtso1

function pbtso1_Callback(hObject, eventdata, handles)

% hObject handle to pbtso1 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

Trang 20

tmp = strcat(tmp,'1');

set(handles.kq,'string',tmp)

end

jj=0;

% - Executes on button press in pbtso2

function pbtso2_Callback(hObject, eventdata, handles)

% hObject handle to pbtso2 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtso3

function pbtso3_Callback(hObject, eventdata, handles)

% hObject handle to pbtso3 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbttru

function pbttru_Callback(hObject, eventdata, handles)

% hObject handle to pbttru (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

Trang 21

% handles structure with handles and user data (see

GUIDATA)

tmp = get(handles.kq,'string');

tmp = strcat(tmp,'-');

set(handles.kq,'string',tmp)

% - Executes on button press in pbtcos

function pbtcos_Callback(hObject, eventdata, handles)

% hObject handle to pbtcos (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtso0

function pbtso0_Callback(hObject, eventdata, handles)

% hObject handle to pbtso0 (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

% - Executes on button press in pbtcham

function pbtcham_Callback(hObject, eventdata, handles)

% hObject handle to pbtcham (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

Trang 22

% handles structure with handles and user data (see

% - Executes on button press in pbtshift

function pbtshift_Callback(hObject, eventdata, handles)

% hObject handle to pbtshift (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

GUIDATA)

% - Executes on button press in pbtcong

function pbtcong_Callback(hObject, eventdata, handles)

% hObject handle to pbtcong (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

GUIDATA)

tmp = get(handles.kq,'string');

tmp = strcat(tmp,'+');

set(handles.kq,'string',tmp)

% - Executes on button press in pbtbang

function pbtbang_Callback(hObject, eventdata, handles)

% hObject handle to pbtbang (see GCBO)

% eventdata reserved - to be defined in a future version ofMATLAB

% handles structure with handles and user data (see

Trang 23

Kết quả:

Ta có được giao diện người dùng (GUI) như một chiếc máy tính điện tử Nhập các

dữ liệu cần tính toán giống như máy tính bỏ túi, kết quả được hiển thị trên màn hình Muốn tính căn bậc 2, sin, cos ta bấm ‘shift+sqrt’, ‘shift+sin’, ‘shift+cos’.

Trang 24

Tính 5+5 Kết quả hiển thị là 10.

Trang 25

Tính Kết quả hiển thị là 10.

Tính Kết quả hiển thị là 0.877583.

Nhận xét:

• Chương trình hiển thị kết quả rõ ràng

• Giao diện đơn giản nhỏ gọn dễ hiểu, dễ sử dụng với người dùng

• Chương trình hoạt động tốt và nhanh chóng

• Đầy đủ chức năng cơ bản để tính toán

Lưu ý: Nút shift có thể phát triển thêm nhiều phép tính thêm nhưng ở đây em chưa phát triển thêm

Ngày đăng: 14/06/2021, 10:40

w