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

Bài tập lớn công cụ mô hình hóa bằng số (3)

13 5 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

Trường Đại học Xây Dựng Ban Kỹ Sư Chất Lượng Cao Bài Tập Mơn Cơng Cụ Mơ Hình Hóa Bằng Số Họ tên: Hoàng Quốc Dũng Lớp: 63 clc1 MSSV: 28263 Bài 1.1: a) 2/2*3 ans = 1.2: a) 2\4 ans =2 1.3: x=2, y=3 z=x z =2 y=y+z y =5 1.4: a=rand a = 0.8147 1.5: >> a=rand a= 0.8147 >> a=36 a = 36 >> b=15 b = 15 >> mod(a,b) ans =6 vecto 2.1: >> A=round(100*rand(1,10)) A = 91 13 91 63 10 28 55 96 96 16 2.2: >> x=[3 6] x= >> x(3) ans = 2.3: >> x=[ 6] x= >> x+16 ans = 18 21 17 22 2.4:>> x=[3 8]' x= >> y=[4 5]' y= >> sum(x)+y ans = 23 20 22 24 2.5: >> n=input('nhap n') x=2:2:2*n nhap n5 n= x= 10 2.6: >> n=input('nhap n') format rat x=((-1).^((1:n)+1))./((2.*(1:n)-1)) n=100 sum(x) nhap n100 n= 100 x= Columns through 10 1/17 -1/3 -1/19 1/5 -1/7 1/9 -1/11 1/13 -1/15 Columns 11 through 20 1/21 -1/23 1/37 -1/39 1/25 -1/27 1/29 -1/31 1/33 -1/35 1/45 -1/47 1/49 -1/51 1/53 -1/55 1/65 -1/67 1/69 -1/71 1/73 -1/75 1/85 -1/87 1/89 -1/91 1/93 -1/95 Columns 21 through 30 1/41 -1/43 1/57 -1/59 Columns 31 through 40 1/61 -1/63 1/77 -1/79 Columns 41 through 50 1/81 -1/83 1/97 -1/99 Columns 51 through 60 1/101 -1/115 -1/103 1/105 1/117 -1/119 -1/107 1/109 -1/111 1/113 Columns 61 through 70 1/121 -1/135 -1/123 1/125 1/137 -1/139 -1/127 1/129 -1/131 1/133 -1/147 1/149 -1/151 1/153 -1/167 1/169 -1/171 1/173 -1/187 1/189 -1/191 1/193 Columns 71 through 80 1/141 -1/155 -1/143 1/145 1/157 -1/159 Columns 81 through 90 1/161 -1/175 -1/163 1/165 1/177 -1/179 Columns 91 through 100 1/181 -1/195 -1/183 1/185 1/197 -1/199 n= 100 ans = 1529/1953 Ma tran 3.1: a) >> x = [1 8] x= >> y = [2 5] y= >> A = [3 ; 7] A= 13 >> x+y ans = 3.2: a) >> A = [2 ; ; 5] A= 8 1 >> A' ans = 3.3: a) >> A = [2 ; ; 9] A= >> x=A(1,:) x= 3.4: A=round(20*rand(4,4)­10) A= 9 -8 -7 -4 -7 -7 a) >> A+15 ans = 21 18 24 24 23 24 15 11 21 23 16 24 3.5: a) >> zeros(4,6) ans = 0 0 0 0 0 0 0 0 0 0 0 0 >> ones(4,5) ans = 1 1 1 1 1 1 1 1 1 1 >> eye(5,5) ans = 0 0 0 0 0 0 0 0 3.6: >> A = [2 ; ; 5; 5] A= 5 a) >> B=A(:,2:2:end) B= 7 5 Vẽ đồ thị 4.1: >> x=0:1:4; >> plot(x,x.^3) Biểu thức logic >> x = [1 1] x= >> y = [5 2 0 2] y= 2 >> x>y ans = 1×7 logical array 1 0 câu lệnh If >> n=2 n= >> if n>1 m=n+1 else m=n-1 end m= Vòng lặp: a) >> x = [1 1] x= >> s=0; >> n=size(x,1)*size(x,2); >> for i=1:n s=s+x(i); end >> s s= 22 >> sum(x) ans = 22 Lập trình >> n=input('nhap Do lon:'); s=[]; if n==1|n==2 s=1; else s=[1 1] for i=3:n s= [s (s(i-1)+s(i-2))]; end end disp(' 10 so Fibonacci dau tien co gia tri lan luot la:') s disp('an phim bat ky de lam tiep phan b') pause m=input('nhap Do lon:'); a=[]; if m==1|m==2 a=1; else a=[1 1] for i=3:m a= [a (a(i-1)+a(i-2))]; end end disp(' 50 so Fibonacci dau tien co gia tri lan luot la:') a disp('ti so giua Fn/Fn-1 cua day so tren la:') for i=2:m A=a(i)/a(i-1) end nhap Do lon:10 s= 1 10 so Fibonacci dau tien co gia tri lan luot la: s= 1 13 21 34 55 an phim bat ky de lam tiep phan b nhap Do lon:10 a= 1 50 so Fibonacci dau tien co gia tri lan luot la: a= 1 13 21 34 55 ti so giua Fn/Fn-1 cua day so tren la: A= A= A= 1.5000 A= 1.6667 A= 1.6000 A= 1.6250 A= 1.6154 A= 1.6190 A= 1.6176 ... vecto 2.1: >> A=round(100*rand(1,10)) A = 91 13 91 63 10 28 55 96 96 16 2.2: >> x=[3 6] x= >> x(3) ans = 2.3: >> x=[ 6] x= >> x+16 ans = 18 21 17 22 2.4:>> x=[3 8]' x= >> y=[4 5]' y= >> sum(x)+y

Ngày đăng: 13/10/2021, 15:45

Xem thêm:

w