| 5 | 1/1 | 返回列表 |
| 查看: 2193 | 回復(fù): 7 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
pianfeng1986鐵蟲(chóng) (初入文壇)
|
[求助]
求教matlab線性優(yōu)化求最小值的問(wèn)題
|
||
|
這兩天遇到這樣一個(gè)問(wèn)題, 目前遇到一個(gè)函數(shù) F(a,b,c,x), 如果定義a,b,c,可以畫(huà)出F在x一個(gè)區(qū)間上的曲線,但無(wú)法求得F的具體解析式。 我的目的是把F曲線與手頭上的實(shí)驗(yàn)曲線達(dá)到最好吻合,同時(shí)求出相應(yīng)的參數(shù)a,b,c。 目前我的思路是這樣的:試驗(yàn)曲線有10000組數(shù)據(jù) (x,y),我用最小二乘的思想,求出每一個(gè)x上對(duì)應(yīng)的F與y之差平方和,即sum((y-F)^2), 然后給出a, b , c的范圍,用fmincon來(lái)求解,但是寫(xiě)了程序,發(fā)現(xiàn)問(wèn)題,程序無(wú)法求出相應(yīng)解。錯(cuò)誤為 Warning: Large-scale (trust region) method does not currently solve this type of problem, switching to medium-scale (line search). > In fmincon at 274 In main at 19 Optimization terminated: magnitude of directional derivative in search direction less than 2*options.TolFun and maximum constraint violation is less than options.TolCon. No active inequalities. 請(qǐng)問(wèn)大神我該怎么辦,是函數(shù)用錯(cuò)了嗎? 還是用別的方法? 主程序如下: clear all;clc; global nr nt apt pidt vb freq nfrq ui=sqrt(-1); nr=50; nt=51; apt=100; pidt=10d0; vb=4212; %% A,b定義約束 45 < x1<55; 0.22 < x2<0.28; 0.0005 < x3<0.001; A=[1,0,0; 0,1,0;0,0,1;-1,0,0;0,-1,0;0,0,-1]; b=[55,0.28,0.001,-45,-0.22,-0.0005]'; x0= [49.13; 0.2592; 0.0007]; % Starting guess at the solution [x,fval] = fmincon(@myfun,x0,A,b) %%_______________________________________ function f = myfun(x); global nr nt apt pidt vb freq nfrq adf=load('y_para.dat'); fs=adf(:,1); con=adf(:,2); freq=fs; nfrq=length(freq); epson= 0.3302 ; ita=0.6052 ; c=1.0888 ; ym=admres(x(1),x(2),epson,ita,c,x(3)); f=sum((real(ym)-con).^2); |
金蟲(chóng) (小有名氣)
榮譽(yù)版主 (著名寫(xiě)手)
彩色掛圖
![]() |
專家經(jīng)驗(yàn): +2 |

鐵蟲(chóng) (初入文壇)
鐵蟲(chóng) (初入文壇)
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|