Prev: WRITING ARRAY TO A FILE AND APPENDING IT
Next: Matlab GUI bar graph with different colors and stacked
From: Don on 21 Jun 2010 16:43 Hi, I am trying to solve system of nonlinear equations with fsolve. The variables are x1 x2, x3, x4,,,,,,,,xi. The solutions should have decreasing values as i increases: Overall shape of xi should have trend of y=1/x with maximum value of x1 (i=1). x1 is order of 10(-6). Since xis are the concentrations, they should be positive or zero. Trial runs give the values of positive and negative values after final iteration. Since the final set of solutions contains negative values for some xis, those should be discarded. The substitution of xi to sqrt(pi) with xi gives solutions of complex numbers for some xis. I wonder whether there is any way to use a constraint in implementing fsolve. If I can use constraint such as xi>=0 or xi for real number during the iteration, it would give reasonable solutions. Any comment would be appreciated.
From: Matt J on 21 Jun 2010 16:55 "Don " <dongmkim(a)yahoo.com> wrote in message <hvoitc$jrt$1(a)fred.mathworks.com>... > I wonder whether there is any way to use a constraint in implementing fsolve. If I can use constraint such as xi>=0 or xi for real number during the iteration, it would give reasonable solutions. > Any comment would be appreciated. ================= You could rewrite the equations you're trying to solve with the change of variables xi=ai^2. Solving for ai will result in nonnegative corresponding values for ai^2=xi. Alternatively, you could just solve using lsqnonlin() and impose positivity bounds explicitly.
From: Don on 21 Jun 2010 17:17 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hvojjo$5db$1(a)fred.mathworks.com>... > "Don " <dongmkim(a)yahoo.com> wrote in message <hvoitc$jrt$1(a)fred.mathworks.com>... > > > I wonder whether there is any way to use a constraint in implementing fsolve. If I can use constraint such as xi>=0 or xi for real number during the iteration, it would give reasonable solutions. > > Any comment would be appreciated. > ================= > > You could rewrite the equations you're trying to solve with the change of variables xi=ai^2. Solving for ai will result in nonnegative corresponding values for ai^2=xi. > > Alternatively, you could just solve using lsqnonlin() and impose positivity bounds explicitly. I already tried ai^2=xi but this second trial gave oscillating solutions. I wonder whether lsqnonlin can be used to solve my system. The solution will not fit any curve or formula. The reason for mentioning y=1/x is to explain decreasing xi for increasing i.
From: Ravi on 21 Jun 2010 23:22 Hi Don, Solve the nonlinear system of equations as an optimization problem. I have used this to solve nonlinear equations with multiple solutions where a particular solution set (such as all non-negative) is required. Min SSE=sum(fi^2) Constraints : -xi<=0 fi are the nonlinear equations xi are the non-negative variables SSE is the error function, SSE>=0. If equations are satisfied SSE will be zero. Hence solution to minimization problem is the solution to the system of equations. If your fi are differentiable, use fmincon. However if your system of equations is not smooth, use Genetic Algorithm. Good luck ! Ravi "Don " <dongmkim(a)yahoo.com> wrote in message <hvokt0$rqc$1(a)fred.mathworks.com>... > "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hvojjo$5db$1(a)fred.mathworks.com>... > > "Don " <dongmkim(a)yahoo.com> wrote in message <hvoitc$jrt$1(a)fred.mathworks.com>... > > > > > I wonder whether there is any way to use a constraint in implementing fsolve. If I can use constraint such as xi>=0 or xi for real number during the iteration, it would give reasonable solutions. > > > Any comment would be appreciated. > > ================= > > > > You could rewrite the equations you're trying to solve with the change of variables xi=ai^2. Solving for ai will result in nonnegative corresponding values for ai^2=xi. > > > > Alternatively, you could just solve using lsqnonlin() and impose positivity bounds explicitly. > > I already tried ai^2=xi but this second trial gave oscillating solutions. > I wonder whether lsqnonlin can be used to solve my system. The solution will not fit any curve or formula. The reason for mentioning y=1/x is to explain decreasing xi for increasing i.
From: Don on 22 Jun 2010 05:30 Thanks Ravi, I looked up my Matlab. Mine is Release-14 and does not have SSE (curve fitting toolbox). I should try other ways as you suggested. "Ravi " <soni_romi(a)yahoo.com.thisisjunkremoveit> wrote in message <hvpa8t$o4s$1(a)fred.mathworks.com>... > Hi Don, > > Solve the nonlinear system of equations as an optimization problem. I have used this to solve nonlinear equations with multiple solutions where a particular solution set (such as all non-negative) is required. > > Min SSE=sum(fi^2) > Constraints : -xi<=0 > > fi are the nonlinear equations > xi are the non-negative variables > > SSE is the error function, SSE>=0. > If equations are satisfied SSE will be zero. > Hence solution to minimization problem is the solution to the system of equations. > > If your fi are differentiable, use fmincon. > However if your system of equations is not smooth, use Genetic Algorithm. > > Good luck ! > > Ravi > > > > > > > > "Don " <dongmkim(a)yahoo.com> wrote in message <hvokt0$rqc$1(a)fred.mathworks.com>... > > "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hvojjo$5db$1(a)fred.mathworks.com>... > > > "Don " <dongmkim(a)yahoo.com> wrote in message <hvoitc$jrt$1(a)fred.mathworks.com>... > > > > > > > I wonder whether there is any way to use a constraint in implementing fsolve. If I can use constraint such as xi>=0 or xi for real number during the iteration, it would give reasonable solutions. > > > > Any comment would be appreciated. > > > ================= > > > > > > You could rewrite the equations you're trying to solve with the change of variables xi=ai^2. Solving for ai will result in nonnegative corresponding values for ai^2=xi. > > > > > > Alternatively, you could just solve using lsqnonlin() and impose positivity bounds explicitly. > > > > I already tried ai^2=xi but this second trial gave oscillating solutions. > > I wonder whether lsqnonlin can be used to solve my system. The solution will not fit any curve or formula. The reason for mentioning y=1/x is to explain decreasing xi for increasing i.
|
Next
|
Last
Pages: 1 2 Prev: WRITING ARRAY TO A FILE AND APPENDING IT Next: Matlab GUI bar graph with different colors and stacked |