## 8-3 ?芥暩?勬???

fzero ノ虫跑计ㄧ计―ㄤㄏノ粂猭

x = fzero(fun, x0)

ㄤい fun 琌饼―ㄧ计﹃ボx0 玥琌癬﹍翴┪癬﹍跋丁眤パ x0 ﹚癬﹍翴┪癬﹍跋丁ㄓ秈︽―fzero 穦沮 x0 ぃτ磅︽笆

• 璝 x0 癬﹍翴玥 fzero 穦笆т箂翴┪ㄧ计跑腹翴跋丁硋˙罽跋丁т箂翴璝 fzero 礚猭т跋丁玥肚 NaN
• 璝ㄏㄧ计ぃ腹ㄢ翴玥иパ x0 钡﹚碝跋丁ㄏ fzero е硉т跋丁ず

ㄒ璝璶т humps  x = 1.5 喷衡ぇ块

Example 1: 08-计厩ㄧ计矪瞶籔だ猂/fzero01.mx = fzero(@humps, 1.5); % ―綼 1.5  y = humps(x); % 盿― fprintf('humps(%f) = %f\n', x , y);humps(1.299550) = 0.000000

いfzero т 1.5 跑腹ㄢ翴 1.26 の 1.6697礛沮т humps 箂翴

Example 2: 08-计厩ㄧ计矪瞶籔だ猂/fzero02.mx = fzero(@humps, [-1, 1]); % ―辅跋丁 [-1, 1]  y = humps(x); % 盿― fprintf('humps(%f) = %f\n', x , y);humps(-0.131618) = 0.000000

 fzero т琌箂翴璝璶礶硂ㄢ箂翴块

Example 3: 08-计厩ㄧ计矪瞶籔だ猂/fzero03.mfplot(@humps, [-1, 2]); grid on z1 = fzero(@humps, 1.5); z2 = fzero(@humps, [-1, 1]); line(z1, humps(z1), 'marker', 'o', 'color', 'r'); % 礶材箂翴竚 line(z2, humps(z2), 'marker', 'o', 'color', 'r'); % 礶材箂翴竚

Example 4: 08-计厩ㄧ计矪瞶籔だ猂/fzero04.mopt = optimset('disp', 'iter'); % 陪ボ– iteration 挡狦 a = fzero(@humps, [-1, 1], opt) Func-count x f(x) Procedure 2 -1 -5.13779 initial 3 -0.513876 -4.02235 interpolation 4 -0.513876 -4.02235 bisection 5 -0.473635 -3.83767 interpolation 6 -0.115287 0.414441 bisection 7 -0.115287 0.414441 interpolation 8 -0.132562 -0.0226907 interpolation 9 -0.131666 -0.0011492 interpolation 10 -0.131618 1.88371e-07 interpolation 11 -0.131618 -2.7935e-11 interpolation 12 -0.131618 8.88178e-16 interpolation 13 -0.131618 8.88178e-16 interpolation Zero found in the interval [-1, 1] a = -0.1316

―箂翴筁祘い穦ノだ猭Bisection┪ず础猭Interpolation硂ㄇよ猭陪ボ Procedure 材逆い璝倒﹚癬﹍翴玥 fzero 程˙艼い穦т続讽跋丁ㄓ穓碝箂翴

Hint
• optimset 硄盽ノ砞﹚程ㄎて匡兜盢竊い冈灿ざ残

MATLAB祘Α砞璸秈顶絞