matlab中求極值點,matlab中求極值點

2021-08-14 14:07:49 字數 2669 閱讀 8061

1樓:匿名使用者

先畫出導數的曲線,根據其零點判斷有幾個極點,然後對各極點分別指定適當的初值,利用fsolve求出準確的零點位置,再繪圖即可.參考**如下:symsxf=-2*x.

^2+4+sin(2*pi*x);df=diff(f);ezplot(df,[-33])x0=[-1.8-1.3-0.

80.50.20.

51.2];x0=fsolve(inline(char(df)),x0,optimset('fsolve'));holdonplot(xlim,[00],'--c')plot(x0,subs(df,x0),'ro')figure(2)ezplot(f,[-33])holdonplot(x0,subs(f,x0),'ro')

2樓:我行我素

可這樣:

t=0:1/2500:0.1;x=sin(t).*cos(2*t);

f1=60;f2=60*37;x1=sin(2*pi*f1*t).*cos(2*pi*f2*t);

plot(t,x,t,x1)

a=max(x),b=min(x)%最大、最小值a1=max(x1),b1=min(x1)%最大、最小值

3樓:匿名使用者

function hh

global dy1 dy2

y='x^2*sin(x^2-x-2)'

dy1=diff(y)

dy2=diff(y,2)

subplot(3,1,1)

ezplot(y,[-2 2])

subplot(3,1,2)

ezplot(dy1,[-2 2]),hold on,plot(-2:2,zeros(length(-2:2)))

subplot(3,1,3)

ezplot(dy2,[-2 2]),hold on,plot(-2:2,zeros(length(-2:2)))

x01=fsolve(@myfun1,[-1.5 -0.7 0 1.6])

x02=fsolve(@myfun2,[-1.9 -1.3 -0.5 1.3])

function f1=myfun1(x)

global dy1

f1=subs(dy1);%very inportamt!!!!!;

function f2=myfun2(x)

global dy2

f2=subs(dy2);%very inportamt!!!!!;

結果:y =

x^2*sin(x^2-x-2)

dy1 =

2*x*sin(x^2-x-2)+x^2*cos(x^2-x-2)*(2*x-1)

dy2 =

2*sin(x^2-x-2)+4*x*cos(x^2-x-2)*(2*x-1)-x^2*sin(x^2-x-2)*(2*x-1)^2+2*x^2*cos(x^2-x-2)

optimization terminated: first-order optimality is less than options.tolfun.

x01 =

-1.5326 -0.7315 0 1.5951

optimization terminated: first-order optimality is less than options.tolfun.

x02 =

-1.9240 -1.2650 -0.4742 1.2404

4樓:匿名使用者

[c,i]=max(x);

c是值, i是位置。

5樓:匿名使用者

data是你的資料,

find(diff(sign(diff(data)))==-2)+1找到極大值的位置

find(diff(sign(diff(data)))==2)+1找到極小值的位置

matlab求極值點

6樓:匿名使用者

>> [x,val]=fminsearch(@(t)2*(atan((t+100)/100)-atan(t-100)/100)-((4/3)*3.14*50*50*50/(t*t+200*200)^2.5)*(2*200*200-t*t),99)

x =101.7850

val =

2.1361

影象>> t=-1000:0.5:1000;

>> f = @(t)2*(atan((t+100)/100)-atan(t-100)/100)-((4/3)*3.14*50*50*50./(t.

*t+200*200).^2.5).

*(2*200*200-t.*t);

>> plot(t,f(t))

matlab中一組資料擬合後怎麼求其極值點,橫座標取值範圍為0-31

7樓:天雲一號

給個例子你看看(我從網上找的)

一元函式的極值的求法是用函式「fminbnd」

%例如求x^2+1在[-2,2]的最小值,f=inline('x.^2+1');%通過行內函數建立函式f[x1,fx]=fminbnd(f,-2,2)%x1為在x=x1時,函式f取得最小值fx%如果想求最大值,則可以用g=-f,g的最小值就是f的最大值。

補充一下,求多元函式的極值的函式是「fminsearch」。

matlab,求二維矩陣的兩個極值點

求二維矩陣的極值點,就是用matlab的兩個命令min,max。如 a magic 5 amin min min a amax max max a 試一下這個 求矩陣a的最小值 min min a 求矩陣a的最大值 max max a matlab如何找到一個陣列中的最大值以及它所在的位置 用max...

關於MATLAB中simulink的求定積分問題,求大神幫忙

關於求函式 exp x.2 在0到1上的積分,可以這樣子 i quadl x exp x.2 0,1 如果你的matlab不支援匿名函式的話,可以用行內函數 i quadl inline exp x.2 0,1 兩種方法都會得到 i 0.7468 當然如果可以建議還是使用匿名函式。關於simulin...

我想用matlab中fminbnd求函式極值。函式裡有個引數,我想多次修改引數值,求對應不同引數的

比如函式是ff x,r 你可以for r 1,3,4 x fminbnd x ff x,r x0 end matlab的fminbnd函式求出的最小值與實際最小值有誤差怎麼消除?本來fminbnd是基於數值計算的肯定存在舍入誤差我們可以增加引數 tolx 設定允許誤差的範圍專只要給err一個很少的值...