(* test data*) plot1=Plot[PDF[LogNormalDistribution[0,1],x],{x,0,5}] mypts=plot1[[1,1,-1,2,1]]; ListLinePlot[mypts] (* models and parameters *) myrule=b[coef_]:>ToExpression["b"<>ToString[coef]]; mymodel=Accumulate[b[#]*x^#&/@Range[0,10,1]/.myrule][[2;;-1]] myvar=b[#]&/@Range[0,10]/.myrule (* fitting models *) myfit=FindFit[mypts,mymodel[[#]],myvar[[1;;#+1]],x]&/@ Range[Length@mymodel] (* plot data and model *) Plot[mymodel[[#]]/.myfit[[#]],{x,0,5},Epilog->Point[mypts], PlotRange->{{0,5},{0,0.8}}]&/@Range[Length@mymodel]
Mathematica 教學:Interpolation 的函數要如何輸出
由 戴忠淵 於 2015年1月6日星期二
上午11:02 發表
讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~