tags:

views:

33

answers:

2

In MATLAB, I have an equation a*x+b=0 for which I have a and b defined during execution. What is the best way I can solve the equation using what I've set for a and b.

+3  A: 

Hi

I guess that you are going to have to use num2str() and related functions to build the equation in the string form that solve() requires. That shouldn't be too difficult should it ?

Regards

Mark

High Performance Mark
solve('a * x + b=0', strcat('a=',num2str(a)), strcat('b=',num2str(b)) );
srand
Thanks @srand, I can never remember syntax so I confine my advice to vague hints.
High Performance Mark
Additionally, of course, sprintf which I forgot about: solve('a * x + b=0', sprintf('a=%d',a), sprintf('b=%d',b) )... long day:)
srand
A: 

Can't you solve symbolically in terms of a and b, and then replace a and b by their value in the result?

Kena
in reality the equation is complex and has many variables
srand

related questions