"Mikey Evans" wrote in message <kuvtv9$gtm$1@newscl01ah.mathworks.com>...
> Hello!
>
> I'm having a bit of a problem with something that I thought would be simple:
>
> I'd like to solve a function
> z = out + x/1000*((0.88 + 0.437*incoming)*(2753.9 + 1.493*incoming) + (0.89 + 0.132*incoming)*(2651.1 + 0.984*incoming));
>
> where x is the variable I'd like to solve and "out" and "incoming" are simply values coming from either other functions or being parameters that I can decide for myself. I
>
> The problem for me is that Matlab can't solve the function in this shape and I have to define "out" and "incoming" with, for example
> incoming = 60;
> out = 5;
>
> and put that in the function
> z = 5+ x/1000*((0.88 + 0.437*60)*(2753.9 + 1.493*60) + (0.89 + 0.132*60)*(2651.1 + 0.984*60));
>
> which then becomes solvable. (I've been using fsolve).
>
> But this isn't practical for me so I wonder how I should define the function so that I could use "out" and "incoming" instead of numbers, to test different scenarios?
         
For this purpose you should be using 'solve', not 'fsolve'. Your example is a simple linear case that it can easily solve. However, you should be aware that for very complicated equations, 'solve' may be unable to find a solution.
Roger Stafford
