[問題] 曲線擬合問題

看板MATLAB作者 (Gary)時間14年前 (2011/11/18 00:37), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
各位板眾大家好 自己摸索學習Matlab 卡在這邊很久了 所以來請教大家 我有一組x.y的數據約600筆 想要對已知"非線性方程"做曲線擬合 方程式為 x=(log((y/b)*((b-c)/(y-c)))-c*(1/y-1/b))/(a*c^2) 想求未知參數a.b.c 並求得R2值 我嘗試用了兩個方法 1. curvefiting 我用Toolboxes裡的Curve Fitting 選擇Custom Equations來輸入自訂函數 可是就是跑不出來 出現 Fit could not be computed due to error: Inf computed by model function, fitting cannot continue. Try using or tightening upper and lower bounds on coefficients. 但是對於參數a.b.c的值 大概有個底 所以對於初始值及上下限都有給值 問題會出現在這邊嗎? 2. lsqcurvefit M.file 輸入 ----------------------------------------------- function F=myfun(x,J); F=(log([(J*(x(2)-x(3)))*diag((x(2)*(J-x(3))).^-1)])-x(3)*(J.^-1-x(2)^-1)) *((x(1)*x(3)^2)^-1) ----------------------------------------------- Command Window輸入 clear;clc xlsFile='data9910031.xls'; x(1,:)=xlsread(xlsFile,'sheet1','A1:A660')'; y(1,:)=xlsread(xlsFile,'sheet1','B1:B660')'; x0=[500000 0.0001 0.00002]; [x,resnorm]=lsqcurvefit(@myfun,x0,x,y) format long; ----------------------------------------------- 擬合的結果很差 也出現根本不可能的負值 還有 請問R2有指令嗎? corrcoef我不會用T^T 我已經困在這裡很久了 請大家有意見的請告訴我~ 謝謝各位!!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.150.220

11/18 19:04, , 1F
數據方便給嗎? 我試看看.或線上聊
11/18 19:04, 1F

11/19 01:16, , 2F
謝謝你:) 已寄信
11/19 01:16, 2F
文章代碼(AID): #1EnJWicV (MATLAB)