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

GIAO TRINH GIỚI THIỆU MATLAB

40 244 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

Cấu trúc

  • Slide 1

  • NỘI DUNG

  • NỘI DUNG

  • Khai báo biến (symbolic)

  • Các hàm sơ cấp cơ bản

  • Các hằng số

  • Gán (=), subs(f), subs(f,new), subs(f,old,new) (thay thế)

  • eval(f) (tính giá trị)

  • Slide 9

  • Slide 10

  • solve(f) : giải pt f = 0

  • real(z), imag(z), angle(z), abs(z)

  • Slide 13

  • Các phép toán so sánh số.

  • Các phép toán so sánh số

  • Phép toán so sánh string (chuỗi ký tự)

  • Các phép toán Logic (Kết quả: 1(đúng), 0(sai)).

  • Các phép toán Logic (Kết quả: 1(đúng), 0(sai)).

  • Các phép toán Logic (Kết quả: 1(đúng), 0(sai)).

  • Lệnh limit (tính giới hạn)

  • Lệnh diff (tính đạo hàm)

  • Slide 22

  • Lệnh int (tính tích phân)

  • Slide 24

  • Vẽ đồ thị: hàm ezplot

  • Slide 26

  • Slide 27

  • Vẽ đồ thị: hàm plot

  • Slide 29

  • Slide 30

  • Slide 31

  • Slide 32

  • Slide 33

  • Viết code

  • Editor

  • Slide 36

  • Slide 37

  • Slide 38

  • Slide 39

  • Slide 40

Nội dung

GIỚI THIỆU MATLAB NỘI DUNG Khai báo biến Các hàm số sơ cấp Lệnh subs, eval Các giá trị đặc biệt Lệnh expand, simplify, solve Các lệnh real, imag Các phép toán so sánh Các phép toán logic NỘI DUNG Lệnh limit, diff, int Các hàm vẽ 10.Code Khai báo biến (symbolic) syms x y syms x y real syms x y positive Các lệnh viết cách khác: x = sym(′x′) x = sym(′x′, ′real′) Các hàm sơ cấp sin ( x ) ,cos ( x ) , tan ( x ) ,cot ( x ) ,sinh ( x ) ,cosh ( x ) asin ( x ) ,acos ( x ) ,atan ( x ) exp ( x ) = e , x a^x=a x sqrt ( x ) = x log ( x ) = ln ( x ) , log10 ( x ) = log10 ( x ) abs ( x ) = | x | Các số pi = π exp(1) = e inf = +∞ NaN = not a number eps = −52 Gán (=), subs(f), subs(f,new), subs(f,old,new) (thay thế) syms x y >> f=sin(x); >> subs(f,x,y) ans = sin(y) >> x=pi/2; >> subs(f) ans = syms x >>f=sin(x); >> subs(f,x,pi) ans = 1.2246e-016 >> subs(f,pi) ans = 1.2246e-016 >> subs(f,x,sym(pi)) ans = eval(f) (tính giá trị) syms x >>f=sin(x); >>x=pi/2; >>eval(f) ans = expand(f) (khai triển), simplify(f) (rút gọn), factor(f) (phân tích thành thừa số với hệ số nguyên) >> expand((x^2-1)*(x^3+x)) ans = x^5 - x >> factor(ans) ans = x*(x - 1)*(x + 1)*(x^2 + 1) >> simplify(ans) ans = x^5 - x >> f=tan(x+y); >> expand(f) ans = -(tan(x) + tan(y))/(tan(x)*tan(y) - 1) >> simplify(ans) ans = tan(x + y) >> >> f=(x+i)*(x-2*j); >> simplify(f) ans = x^2 - x*i + >> factor(ans) ans = (x - 2*i)*(x + i) x3 - x2 + x3 - x2 + 150 16 100 14 50 12 10 -50 -100 -150 -200 -250 -300 -2 -350 -4 -6 -4 -2 x 0.5 1.5 x 2.5 >> syms x >> ezplot(f,0,4) >> f=x^3-3*x^2+1; >> ezplot(f,[0,4]) >> ezplot(f) 3.5 x3 - x2 + 16 14 12 10 -2 -4 0.5 1.5 x 2.5 3.5 >> h=ezplot(f,[0,4]); >> set(h,'Color','g','LineWidth',2,'LineStyle',' ') Vẽ đồ thị: hàm plot x = linpace ( a, b, n ) ; y = subs ( f ); plot ( y,' LineSpec ',' PropertiesName′) plot ( x, y , LineSpec ',' PropertiesName′) t = linpace ( a, b, n ) ; x = subs ( x(t ) ) ; y = subs ( y (t )); plot ( x, y ,' LineSpec ',' PropertiesName′) plot ( x, y , LineSpec ',' PropertiesName′) 20 15 10 -5 0.5 1.5 2.5 >> x=linspace(0,4,50); >> y=x.^3-3*x.^2+1; >> plot(y); 3.5 20 15 10 20 15 10 -5 0.5 1.5 2.5 >> plot(x,y,‘*r'); 3.5 -5 0.5 1.5 2.5 3.5 >> plot(x,y,'Color','r','LineWidth',2,'LineStyle',' ') x 3-3*x 2+1 20 15 10 -5 0.5 1.5 2.5 >> plot(x,y,'*r') >> title('x^3-3*x^2+1') >> grid on 3.5 >> syms x >> f=x^3 - 3*x^2 + >> x0=-1;y0=subs(f,x,x0); >> k=subs(diff(f),x,x0); >> X=linspace(x0-3,x0+3,30); >> Y=subs(f,x,X);Y1=subs(y,x,X); >> plot(X,Y,'Color','b','LineWidth',2); hold on >> plot(X,Y1,'Color','r','LineWidth',2); >> plot(x0,y0,'om','MarkerFaceColor','m'); >> legend('duong cong','tiep tuyen','tiep diem') >> grid on >> title('Minh hoa thi va tiep tuyen','Color','c’) Minh hoa thi va tiep tuyen 40 duong cong tiep tuyen tiep diem 20 -20 -40 -60 -80 -100 -120 -4 -3 -2 -1 Viết code File → New → Script/ Function: chuyển sang Editor Editor Sau soạn phải lưu thành file Đặt tên chọn nơi lưu file Chọn save để lưu file (ở lưu vào desktop) Bấm F5 để chạy chương trình từ Editor Chọn ‘Change Folder’/ ‘Add to Path’ Chương trình xuất yêu cầu kết Command W ... x3 - x2 + x3 - x2 + 150 16 100 14 50 12 10 -5 0 -1 00 -1 50 -2 00 -2 50 -3 00 -2 -3 50 -4 -6 -4 -2 x 0.5 1.5 x 2.5 >> syms x >> ezplot(f,0,4) >> f=x^ 3-3 *x^2+1; >> ezplot(f,[0,4]) >> ezplot(f) 3.5 x3 -. .. ans = >> > 1-2 ~=0 ans = >> 1-2 ~ =-1 ans = >> 1-3 ==2 ans = >> 1-3 = =-2 ans = Các phép toán so sánh số >> f=x^ 3-3 *x^2+x+2; >> s=solve(f) s= 5^(1/2)/2 + 1/2 1/2 - 5^(1/2)/2 >> s(1)> syms(real(z)) >> abs (-2 ) ans = >> s=solve(x^2+x+1) s= - 1/2 + (3^(1/2)*i)/2 - 1/2 - (3^(1/2)*i)/2 >> real(s(1)) ans = -1 /2 >> imag(s(2)) ans = -3 ^(1/2)/2 >> Các

Ngày đăng: 09/12/2016, 14:08

TỪ KHÓA LIÊN QUAN

w