Path: news.mathworks.com!not-for-mail
From: "Ben Hinkle" <bhinkle@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solve Equation Symbolically
Date: Mon, 12 Nov 2007 16:03:21 -0500
Organization: The MathWorks, Inc.
Lines: 33
Message-ID: <fhaf2r$o6i$1@fred.mathworks.com>
References: <fha99r$osc$1@fred.mathworks.com>
Reply-To: "Ben Hinkle" <bhinkle@mathworks.com>
NNTP-Posting-Host: hinkleb.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1194901403 24786 172.31.57.121 (12 Nov 2007 21:03:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 12 Nov 2007 21:03:23 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
Xref: news.mathworks.com comp.soft-sys.matlab:437170




"evan klinger" <eklinger1-nospam@cox.net> wrote in message 
news:fha99r$osc$1@fred.mathworks.com...
> Good afternoon all,
>
> I am trying to solve the equation cv3 below using the solve
> command but for some reason Matlab is not able to solve for
> x. Or it returns strange constants in the result. It also
> sometimes is dropping some of the symbols. I am just trying
> to find out what x equals to. Any help would be greatly
> appreciated.
> cv0, p[n], x, db and cr are all symbols
>
> cv1 = (cv0 + p1 - (x)*(db-cv0))*(1+cr)
> cv2 = (cv1 + p2 - (x)*(db-cv1))*(1+cr)
> cv3 = (cv2 + p3 - (x)*(db-cv2))*(1+cr)
>
> I was using solve(cv3, 'x') but this is giving strange
> constants.

Since MATLAB uses 'x' as the default independent variable all you need to do 
is:

syms cv0 p1 p2 p3 x db cr
cv1 = (cv0 + p1 - (x)*(db-cv0))*(1+cr)
cv2 = (cv1 + p2 - (x)*(db-cv1))*(1+cr)
cv3 = (cv2 + p3 - (x)*(db-cv2))*(1+cr)
solve(collect(expand(cv3))

Hope that helps,
-Ben Hinkle