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
.
views:
33answers:
2
+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
2010-02-09 22:54:06
solve('a * x + b=0', strcat('a=',num2str(a)), strcat('b=',num2str(b)) );
srand
2010-02-09 22:58:53
Thanks @srand, I can never remember syntax so I confine my advice to vague hints.
High Performance Mark
2010-02-09 23:00:05
Additionally, of course, sprintf which I forgot about: solve('a * x + b=0', sprintf('a=%d',a), sprintf('b=%d',b) )... long day:)
srand
2010-02-09 23:06:13