1. Trang chủ
  2. » Giáo Dục - Đào Tạo

BÁO cáo môn học TIN học kỹ THUẬT bài 1 cơ sở về MATLAB

24 2 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

Nội dung

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC CÔNG NGHỆ TP HCM VIỆN KỸ THUẬT BÁO CÁO MÔN HỌC TIN HỌC KỸ THUẬT Giảng viên hướng dẫn: Phạm Nguyễn Nhựt Thanh Sinh viên thực hiện: Nguyễn Trung Kiên Mã SV: 2180500458 Ngành: Kỹ thuật điều khiển tự động hoá Lớp: 21DTDA1 Tp.HCM, ngày 13 tháng 10 năm 2022 BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC CÔNG NGHỆ TP HCM VIỆN KỸ THUẬT BÁO CÁO TIN HỌC KỸ THUẬT Tên SV: Nguyễn Trung Kiên Mã SV: 2180500458 Lớp: 21DTDA1 BÀI 1: CƠ SỞ VỀ MATLAB I.GIỚI THIỆU MATLAB ( Matrix laboratory) phần mềm để giải toán kỹ thuật,đặt biệt toán liên quan đến ma trận.MATLAB cung cấp vấn đề đặt biệt sử lý tín hiệu số,hệ thống điều khiển.mạng neuron,fuzzy logic,mô II.CÁC VẤN ĐỀ CƠ BẢN Các phép tốn tốn tử Viết đoạn chương trình giải phương trình bậc 2: a=1; b=-2; c=1; delta=b^2-4*a*c; x1=(-b+sqrt(delta))/(2*a) x2=(-b-sqrt(delta))/(2*a) Ma trận -Nhập ma trận thực lệnh A=[16 13;5 10 11 8;9 12;4 15 14 11]; sum(A) A' Nối ma trận Ví dụ 1.3: a=ones(3,3); b=5*ones(3,3); c=[a+2;b] For -Xây dựng chương trình đốn số: x=fix(100*rand); n=7; t=1; for k=1:1:7 num=int2str(n); disp(['Ban co quyen du doan''num''lan']); disp('So can doan khoang 0-100'); g=input('Nhap so ma ban doan:'); if gx disp('So ban doan lon hon'); else disp('Ban da doan dung.Xin chuc mung'); t=0; break; end n=n-1; end if t>0 disp('Ban khong doan roi'); numx=int2str(x); disp(['Do la so: ''numx']); end Các phép toán hàm tốn học -Ta có hàm three_var.m function b = three_var(v) x = v(1); y = v(2); z = v(3); b=x.^2+2.5*sin(y)-z^2*x^2*y^2; v=[-0.6 -1.2 0.135]; a=fminsearch('three_var',v) -Tìm điểm zero III ĐỒ HOẠ Vẽ hàm số tan(sin(x))-sin(tan(x)) x=-pi:pi/10:pi;y=tan(sin(x))-sin(tan(x)); plot(x,y,' rs','Linewidth',2,'MarkerEdgeColor','y', 'MarkerFaceColor','b','MarkerSize',10) hold on y=sin(x) Vẽ hai trục Y t=0:900;A=1000;b=0.005;a=0.005;z2=sin(b*t); z1=A*exp(-a*t); plotyy(t,z1,t,z2,'semilogy','plot'); Vẽ đường công 3D t=0:pi/50:10*pi; plot3(sin(t),cos(t),t) Vẽ nhiều trục toạ độ x=linspace(0,2*pi); y1=sin(x);y2=cos(x);y3=2*exp(-x).*sin(x); x1=linspace(-2*pi,2*pi);y4=sinc(x1); subplot(221);plot(x,y1);title('Ham y= sinx'); subplot(222);plot(x,y2);title('Ham y= cosx'); subplot(223);plot(x,y3);title('Ham y = 2e^{-x}sinx'); subplot(224);plot(x1,y4);title('Ham y = $${sin \pi x\ over \ pi x}$$','interpreter','latex'); Giới hạn trục chia vạch trục x = -pi:.1:pi; y = sin(x); plot(x,y) set(gca,'xtick',-pi:pi/2:p); set(gca,'xticklabel',{'-pi','-pi/2','0','pi/2','pi'}) Ghi nhãn lên trục toạ độ t=0:900; plot(t,0.25*exp(-0.005*t)) text(300,.25*exp(-.005*300),'\bullet\leftarrow \ fontname{time}0.25{\ite}^{-0.005{\itt}}at, {\ itt}=300','FontSize',14) title('\ite{i\omege_0\tau} = cos(\omega_0\tau) + sin( \ omega_0\tau)') Đồ hoạ đặt biệt: +Khối vùng y = [5 ; ; 3;5 5 ; 8]; subplot(211); bar(y); subplot(212); bar3(y); +Xếp chồng đồ thị TCE = [515 420 370 250 135 120 60 20]; nhdo = [29 23 27 25 20 23 23 27]; = 0:5:35; bar(ngay,nhdo); xlabel('Ngay'); ylabel('Nhiet (^{o}C)'); -Đồ hoạ 3D [x,y] = meshgrid(-8:.5:8); r = sqrt(x.^2 + y.^2); z = sin(r)./r;mesh(z) *CÂU HỎI ÔN TẬP BT 1: Dùng hàm text viết công thức sau trục toạ độ text('position',[.1 2], 'fontsize',14,'interpreter','latex','string',['$$\hbox {y= x} \left({\matrix{x & x^2 & x^3 \cr x^2 & x^3 & x \cr x^3 & x & x^2}} \right)$$']); text('position', [.1 4],'fontsize',14,'interpreter','latex','string','$$ \ sum_{n=-1}^\infty {z^{-n} {x(n)}}$$'); text('position', [.1 6],'fontsize',14,'interpreter','latex','string','$$\ int_{- \infty}^{\infty} \frac {e^{-x}+e^{x}}{\sqrt{2x + 1}} {sin (\omega( x -\pi))dx}$$'); BT 2: Viết đoạn script vẽ hàm số x=linspace(-10,10,100) y=exp(-x)./(2*exp(-x)+2) plot(x,y) BÀI 2: GIAO DIỆN ĐỒ HOẠ-GUI Tạo GUI Đối tượng Button Radio Button Static text Static text Đối tượng Slider Edit text Edit text Thông số String:Convert Tag: pushbuttonConvert String: Celcius,Rakine,Kelvin Value: 1.0,0.0,0.0 Tag: radiobuttonC,radiobuttonR,radiobuttonK String: Fahrenheit dgree String: Celcius degree Tag: text2 Thông số Max: 9032 Min: -459.4 SliderStep: [0.001 0.1] Tag: SliderDoF Value: 32 String: 32 Tag: editDoF String: Tag: editKQ Chương trình % - Executes on button press in pushbuttonConvert function pushbuttonConvert_Callback (hobject, eventdata, handles) % hobject handle to pushbuttonConvert (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) doF = str2num(get (handles.editDoF, 'String' )); if get (handles radiobuttonC, 'Value') == % Chuyen oC set (handles.editKI, 'String',num2str ( (doF-32) *5/9)); elseif get (handles radiobutton, 'Value') == %Chuyen OR set (handles.editK9, 'String', doF+459.7); else %Chuyen oK end set (handles.editkQ, 'String', (doF-32) *5/9+273.15); % -Executes on button press in radiobuttonC function radiobuttonC_Callback (hobject, eventdata, handles) % hobject handle to radiobuttonC (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get (hObject, 'Value') returns toggle state of radiobuttonC set (handles radiobuttonk, 'Value", 0); Let (handles radiobuttonR, 'Value", 0); set (handles text2, 'String', 'Celcius degree'); I- Executes on button press in radiobuttonR function radiobutton_Callback (hobject, eventdata, handles) % hobject handle to radiobutton (see GCBO) eventdata reserved - to be defined in a future version of MATLAB & handles structure with handles and user data (see GUIDATA) % Hint: get (hObject, 'Value') returns toggle state of radiobutton set (handles radiobuttonC, 'Value', 0); set (handles radiobuttonK, 'Value', 0); set (handles text2, 'String', 'Rankine degree'); % - Executes on button press in radiobuttonK function radiobuttonK Callback (hObject, eventdata, handles) % hobject handle to radiobuttonK (see GCBO) % eventdata reserved - to be defined in a future version of MATIAB % handles structure with handles and user data (see GUIDATA) % Hint: get (hObject, 'Value') returns toggle state of radiobuttonk set (handles radiobuttonR, 'Value', 0); Set (handles radiobuttonC, 'Value', 0); set (handles text2, 'String', 'Kelvin degree'); - Executes on slider movement.so function sliderDoF_Callback (hob ject, eventdata, handles) & hobject handle to sliderDoF (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, 'Value') returns position of slider) % get (hobject, 'Min' ) and get (hObject, 'Max') to determine range of slider set (handles editDoF, 'String', get (handles.sliderDoF, 'Value')); BÀI 3: SYMBOLC Đạo hàm vi phân syms x y=diff(cos(x)) diff(x^3+3*x^2+2*x-1,2) y = diff(x/(1+x^3)) syms m z=2*sin(x)+m^2*cos(x) diff(z,m,2) diff(z,x,3) Tích phân y = int(1/(1+x^2)) y = int(log(x)/exp(x^2)) y = int(x*log(1+x),0,1) y = int(x^3*atan(x),0,pi/4) eval(y) y = inline(log(x)./exp(x.^2)); quad(y,0,1) Hàm ngược syms a b finverse(1/x) finverse(a*x+b) finverse(x^2) Vẽ đồ thị syms x subplot(211);ezplot(sin(x)/x) subplot(212);ezplot(sin(x)/x,0,4*pi) ezsurf(x*exp(-x^2-y^20)) Định dạng biểu thức syms s y=int(sin(s+2*x),s,pi/2,pi) pretty(y) f=sym(x^2-1); factor(f) y=expand((x+1)^3-2*(x-1)^2) y=simplify(sin(x)^2+cos(x)^2) y=simplify((1-x^2)/(1-x)) simplify((1/x^3+6/x^2+12/x+8)^(1/13)) Giải phương rình hệ phương trình -Giải phương trình bậc n: y=solve(x^3+2*x^2+1==0) y=vpa(y) eval(y) Tìm giới hạn -Dùng hàm limit tìm giới hạn hàm syms x a t h y=limit(sin(x)/x) y=limit(sin(x)/x,inf) limit(1/x,x,0,'right') limit(1/x,x,0,'left') limit((sin(x+h)-sin(x))/h,h,0) *CÂU HỎI ƠN TẬP BT 1: Tính vẽ đạo hàm y=diff(sin(x^3)) syms x ezplot(sin(x^3)) y= 3*x^2*cos(x^3) BT 2: Tính tích phân syms x y=int((x^2*(2*x^2+1))/(5*(x^3+3)),-1,1) y= log(2)/15 - (2*pi*3^(1/6))/5 + (3^(2/3)*log(3^(1/3) + 3^(2/3) + 1))/15 (2*3^(1/6)*atan(3^(5/6)/(2*(3^(1/3)/2 - 1))))/5 + (2*3^(1/6)*atan(3^(5/6)/(2*(3^(1/3)/2 + 1))))/5 - (3^(2/3)*log(3^(2/3) - 3^(1/3) + 1))/15 - (2*3^(2/3)*log(3^(1/3) - 1))/15 + (2*3^(2/3)*log(3^(1/3) + 1))/15 BT 3: Giải hệ phương trình syms x y [x,y]=solve(x^2*sin(x^2)-y==7,x-y==2) x= -5.0132041491753126897135846656655 y= -7.0132041491753126897135846656655 BT 4: Vẽ mặt có phương trình sau syms x ezsurf(x/(2*x^2+y^2)) BT 5: Tính đạo hàm cấp hàm số syms x y=diff((1-x)*exp(x^2+2*x)) y= - exp(x^2 + 2*x) - exp(x^2 + 2*x)*(2*x + 2)*(x - 1) BÀI 4: SIMULINK Transfer Fcn nhập Denominator [1 -1 3] ... ĐÀO TẠO TRƯỜNG ĐẠI HỌC CÔNG NGHỆ TP HCM VIỆN KỸ THUẬT BÁO CÁO TIN HỌC KỸ THUẬT Tên SV: Nguyễn Trung Kiên Mã SV: 218 0500458 Lớp: 21DTDA1 BÀI 1: CƠ SỞ VỀ MATLAB I.GIỚI THIỆU MATLAB ( Matrix laboratory)... 2: a =1; b=-2; c =1; delta=b^2-4*a*c; x1=(-b+sqrt(delta))/(2*a) x2=(-b-sqrt(delta))/(2*a) Ma trận -Nhập ma trận thực lệnh A= [16 13 ;5 10 11 8;9 12 ;4 15 14 11 ]; sum(A) A'' Nối ma trận Ví dụ 1. 3: a=ones(3,3);... y=int((x^2*(2*x^2 +1) )/(5*(x^3+3)), -1, 1) y= log(2) /15 - (2*pi*3^ (1/ 6))/5 + (3^(2/3)*log(3^ (1/ 3) + 3^(2/3) + 1) ) /15 (2*3^ (1/ 6)*atan(3^(5/6)/(2*(3^ (1/ 3)/2 - 1) )))/5 + (2*3^ (1/ 6)*atan(3^(5/6)/(2*(3^ (1/ 3)/2 + 1) )))/5

Ngày đăng: 09/12/2022, 10:49

w