From: Lovinash on
hey there,

Say I want to solve a quadratic equation f(x) as part of an algorithm. This will give me two values of x. Lets call these values x1 and x2. can i then use these values for further analysis? for example,

if x1>2
do something
else
do something else

I hope that i am being clear enough on what i want to do. it seems to me that matlab aways give the answer in terms of a vector.. but what if i want to use the individual values further in my algorithm? what do i do?

thanks
Nash
From: Steven Lord on

"Lovinash " <lovi_bono(a)hotmail.com> wrote in message
news:hkcpk3$ahs$1(a)fred.mathworks.com...
> hey there,
>
> Say I want to solve a quadratic equation f(x) as part of an algorithm.
> This will give me two values of x. Lets call these values x1 and x2. can
> i then use these values for further analysis? for example,
>
> if x1>2
> do something
> else
> do something else
> I hope that i am being clear enough on what i want to do. it seems to me
> that matlab aways give the answer in terms of a vector.. but what if i
> want to use the individual values further in my algorithm? what do i do?

theroots = roots([1 2 -1]);
if theroots(1) > 2
% do something
end

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ