9-3 ��������������������?

x}[P@¶q]Scalar^[Aߤ@nDOGۥ[ά۴x}ݨ㦳ۦPסCYפ@PAh MATLAB |Ϳ~TAҦpG

Example 1: 09-x}BzPB/matrix12.mA = [12 34 56 20]; B = [1 3 2 4]; C = A + B C = 13 37 58 24

Ynix}P¶q[A@몺@kON¶qi}Ψx}C@ӤAdҦpUG

Example 2: 09-x}BzPB/matrixAndScalarOperation.mA=[1 3 5]; fprintf('A = '); disp(A); fprintf('A+5 = '); disp(A+5); fprintf('A-3 = '); disp(A-3); fprintf('2*A = '); disp(2*A); fprintf('A/3 = '); disp(A/3); A = 1 3 5 A+5 = 6 8 10 A-3 = -2 0 2 2*A = 2 6 10 A/3 = 0.3333 1.0000 1.6667

Hint
WzdҪҥ~p|oͦb¶qHx}AҦp 5/AAo@kNb򳹸`QסC

Yix}ۭAݽT{Ĥ@ӯx}ƥء] Column Dimension^ ݵĤGӯx}Cƥء]Row Dimension^A_hLkix}ۭAMATLAB |Ϳ~TCHUO@ӯx}ۭ²dҡG

Example 3: 09-x}BzPB/matrix13.mA = [1; 2]; B = [3, 4, 5]; C = A*B C = 3 4 5 6 8 10

x}kA`ǥѤϯx}θѽuʤ{ӹFAiѨѩnf@uMATLAB{]pGigvĤuuʥNơvĤ@`βĥ|`C

x}BAiѡu^vӹFAx}ݬO}A䦸B~NqAҦpG

Example 4: 09-x}BzPB/matrix14.mA = magic(3); B = A^2 B = 91 67 67 67 91 67 67 67 91

Ybu*vAu/vΡu^ve[W@ӥyIAMATLAB N|x}u露v]Element-by-element^ BAҦpG

Example 5: 09-x}BzPB/elByEl01.mA = [12; 45]; B = [2; 3]; C = A.*B % `Nu*veyI D = A./B % `Nu/veyI E = A.^2 % `Nu^veyI C = 24 135 D = 6 15 E = 144 2025

@ӽƼƯx} zAu@mmvx}]Conjugate Transpose^ iܦx} z'AҦpG

Example 6: 09-x}BzPB/conjTranspose01.mi = sqrt(-1); % z = [1+i, 2; 3, 1+2i]; w = z' % @mm]`N z ᭱޸^ w = 1.0000 - 1.0000i 3.0000 + 0.0000i 2.0000 + 0.0000i 1.0000 - 2.0000i

YuQox} z m]Transpose^Ahiܦx} z.'AҦpG

Example 7: 09-x}BzPB/transpose01.mi = sqrt(-1); % z = [1+i, 2; 3, 1+2i]; w = z.' % m]`N z ᭱yIγ޸^ w = 1.0000 + 1.0000i 3.0000 + 0.0000i 2.0000 + 0.0000i 1.0000 + 2.0000i

Y z ơAh z' M z.' GO@˪C]@`Ǫ~A|ѤFx} z iOƼơA]N z ~{Oªx}mC^

@ӦVq a Lp-norm iHwq $$ \|a\|_p = \left(\sum_i |a_i|^p \right)^{1/p} $$

p=2 ɡAYVq a סAκټڤס]Euclidean Length^CD@Vq Lp-normAiϥ norm OAϥλykpUG

norm(x, p)

dҦpU

Example 8: 09-x}BzPB/normVector01.ma = [3 4]; x = norm(a, 1) y = norm(a, 2) z = norm(a, inf) x = 7 y = 5 z = 4

Hint
AO_iHҩUCH
  • norm(a, 1)=$\sum_i |a_i|$
  • norm(a, inf)=$max_i |a_i|$

@ӯx} A p-norm iHwqpUG $$ \|A\|_p = max_x \frac{\|Ax\|_p}{\|x\|_p} $$

MATLAB norm OiΩpx} p-normAҦpG

Example 9: 09-x}BzPB/normMatrix01.mA = [1 2 3; 4 5 6; 7 8 9]; norm(A, 2) ans = 16.8481

MATLAB ٦۷㪺ƾǨƤΤTơAiHΩVqίx}CHUNƾǨƦCzpUG

abs(x) ¶qȩΦVq
angle(z) Ƽ z ۨ]Phase Angle^
sqrt(x) }
real(z) Ƽ z 곡
imag(z) Ƽ z 곡
conj(z) Ƽ z @mƼ
round(x) |ˤJ̪ܳ
fix(x) LץtA˥hpƦ̪ܳ
floor(x) aOơAY˥hpƦ̪ܳ
ceil(x) ѪOơAY[JpƦ̪ܳ
rat(x) N x Ƭƪ
rats(x) N x ƬhƮi}
sign(x) Ÿơ]Signum function^G$sign(x)=\left\{\begin{matrix}-1, x<0\\0, x=0\\1, x>0\end{matrix}\right.$
rem(x,y) D x Hyl
gcd(x,y) x M y ̤j]
lcm(x,y) x M y ̤p
exp(x) ۵M
pow2(x) 2
log(x) H e ơAY۵M
log2(x) H 2
log10(x) H 10

`ΪTƤ]CzpUG

sin(x)
cos(x) l
tan(x)
asin(x) ϥ
acos(x) Ͼl
atan(x) ϥ
atan2(x,y) |Hϥ
sinh(x) WV
cosh(x) WVl
tanh(x) WV
asinh(x) ϶WV
acosh(x) ϶WVl
atanh(x) ϶WV

~AMATLAB ٦@ǨƬOwVqέpqӳ]pAҦp min]DVqpȡ^Bmean]DVqȡ^ACzpUG

min(x) Vq x ̤p
max(x) Vq x ̤j
mean(x) Vq x
median(x) Vq x
std(x) Vq x зǮt
diff(x) Vq x ۾Ft
sort(x) Vq x iƧǡ]Sorting^
length(x) Vq x Ӽ
norm(x) Vq x ڤ]Euclidean^
sum(x) Vq x `M
prod(x) Vq x `n
cumsum(x) Vq x ֭p`M
cumprod(x) Vq x ֭p`n
dot(x, y) Vq x M y n
cross(x, y) Vq x M y ~n

ҦpAsort OiVqiƧǡ]Sorting^G

Example 10: 09-x}BzPB/sort01.mx = [3 5 8 1 4]; [sorted, index] = sort(x) % x} x iƧ sorted = 1 3 4 5 8 index = 4 1 5 2 3

䤤 sorted OƧǫ᪺VqAindex hOCӱƧǫ᪺bVq x mAyܻAx(index) Y sorted VqCt@Ӧ쪺DGpϥ sort O[WeҤ sorted index ӨDoVq xH]DNdUŪ̥hm\aI^

WzCƤj]AΩx}AL̥uONx}VqXAӳv@VqiBCҦpGX@x}̤jmAiJpUG

Example 11: 09-x}BzPB/max01.mx = magic(5); [colMax, colMaxIndex] = max(x) colMax = 23 24 25 21 22 colMaxIndex = 2 1 5 4 3

䤤 colMax NC@檺̤jȡAcolMaxIndex hOC@X{̤jȪmCYnDo x ̤jmAiJpUG

Example 12: 09-x}BzPB/max02.mx = magic(5); [colMax, colMaxIndex] = max(x); [maxValue, maxIndex] = max(colMax); fprintf('Max value = x(%d, %d) = %d\n', ... colMaxIndex(maxIndex), maxIndex, maxValue);Max value = x(5, 3) = 25

ѦiHݥXAx} x ̤jYO maxValueAӨoͦm [colMaxIndex(maxIndex), maxIndex] = [5 , 3]C

Hint
YunX@x} x ̤jȡAiJ max(max)άO max(x(G))C


MATLAB{]pGJg