From: chunte Liu on 14 Jan 2010 06:17 i use the nlinfit function to estimate required coeffcients, but error using message is as belows: The model function 'ZeroPara2' generated the following error: Error: File: D:\MATLAB71\work\ZeroPara2.m Line: 6 Column: 65 Expression or statement is incorrect--possibly unbalanced (, {, or [. My function M-file is the following: function [yhat] = ZeroPara2(beta,xd) b0=beta(1) ; b1=beta(2) ; b2=beta(3) ; b3=beta(4) ; tau1=beta(5) ; tau2=beta(6) ; yhat = b0 + b1*(tau1*(xd(:,1)-xd(:,1).*xd(:,2).^(1/tau1)) +... b2*(tau1*(xd(:,1)-xd(:,1).*xd(:,2).^(1/tau1))-xd(:,2).^(1/tau1)) +... b3*(tau2*(xd(:,1)-xd(:,1).*xd(:,2).^(1/tau2))-xd(:,2).^(1/tau2)); data xd = [1.382575757575758 0.485154602289578 0.581210191082803 0.178968056351136 0.50624133148405 0.13871379938184 0.446210268948655 0.106341901428836 0.336405529953917 0.051169954788209 0.310902896081772 0.040097617669829 0.298202614379085 0.034964407708129 0.268579838116262 0.024154425353175 0.23639896373057 0.014550397206792 0.211716937354988 0.008885916500743 0.204941044357103 0.007601177915677 0.185939887926643 0.00461666732794 0.112273146724085 0.000135457947676 0.106944037503662 0.000086905874133 0.101360733129686 0.000051922754996 0.053183738889698 0.000000006824548 0.050505050505051 0.000000002517499 ] beta = [ 0.0354 -0.0359 0.0116 -0.0421 3 5] yy = [0.002548375755461 0.004 0.004283573886654 0.005712043463536 0.007089420170853 0.007191313927903 0.008427965449558 0.009091147006718 0.009364957799416 0.009118526261253 0.010373908638966 0.011153044212256 0.015491358173832 0.014404379540271 0.014359030541486 0.021130073596078 0.022552043565659] and finally i use betahat = nlinfit(xd,yy,'ZeroPara2',beta) Please give me advices to correct these errors
From: Wayne King on 14 Jan 2010 06:32 "chunte Liu" <chunteliu(a)yahoo.com.tw> wrote in message <himufg$sb6$1(a)fred.mathworks.com>... > i use the nlinfit function to estimate required coeffcients, but error using message is as belows: > The model function 'ZeroPara2' generated the following error: > Error: File: D:\MATLAB71\work\ZeroPara2.m Line: 6 Column: 65 > Expression or statement is incorrect--possibly unbalanced (, {, or [. > > My function M-file is the following: > function [yhat] = ZeroPara2(beta,xd) > b0=beta(1) ; b1=beta(2) ; b2=beta(3) ; b3=beta(4) ; > tau1=beta(5) ; tau2=beta(6) ; > yhat = b0 + b1*(tau1*(xd(:,1)-xd(:,1).*xd(:,2).^(1/tau1)) +... > b2*(tau1*(xd(:,1)-xd(:,1).*xd(:,2).^(1/tau1))-xd(:,2).^(1/tau1)) +... > b3*(tau2*(xd(:,1)-xd(:,1).*xd(:,2).^(1/tau2))-xd(:,2).^(1/tau2)); > > data > xd = [1.382575757575758 0.485154602289578 > 0.581210191082803 0.178968056351136 > 0.50624133148405 0.13871379938184 > 0.446210268948655 0.106341901428836 > 0.336405529953917 0.051169954788209 > 0.310902896081772 0.040097617669829 > 0.298202614379085 0.034964407708129 > 0.268579838116262 0.024154425353175 > 0.23639896373057 0.014550397206792 > 0.211716937354988 0.008885916500743 > 0.204941044357103 0.007601177915677 > 0.185939887926643 0.00461666732794 > 0.112273146724085 0.000135457947676 > 0.106944037503662 0.000086905874133 > 0.101360733129686 0.000051922754996 > 0.053183738889698 0.000000006824548 > 0.050505050505051 0.000000002517499 ] > beta = [ 0.0354 -0.0359 0.0116 -0.0421 3 5] > yy = [0.002548375755461 > 0.004 > 0.004283573886654 > 0.005712043463536 > 0.007089420170853 > 0.007191313927903 > 0.008427965449558 > 0.009091147006718 > 0.009364957799416 > 0.009118526261253 > 0.010373908638966 > 0.011153044212256 > 0.015491358173832 > 0.014404379540271 > 0.014359030541486 > 0.021130073596078 > 0.022552043565659] > and finally i use betahat = nlinfit(xd,yy,'ZeroPara2',beta) > > Please give me advices to correct these errors Hi, I think you need to add a right parenthesis at the end of your first line in the definition of yhat (in your Matlab program): yhat = b0 + b1*(tau1*(xd(:,1)-xd(:,1).*xd(:,2).^(1/tau1)) +... should read yhat = b0 + b1*(tau1*(xd(:,1)-xd(:,1).*xd(:,2).^(1/tau1)))+... see if that gives you the expected yhat results. Wayne
|
Pages: 1 Prev: how can covert grb to his Next: error using the moving average function |