Alan Weiss <aweiss@mathworks.com> wrote in message <hltv3t$ih6$1@fred.mathworks.com>...
> Sorry, I misspoke. Here's what I meant:
>
> %Your setup
> >> syms lamda
> >> Ident_matrix = lamda*eye(3);
> >> A = [0,.75,0;0.75,0,0.25;0,0.25,0];
> >> Result = AIdent_matrix;
> >> eq = det(Result);
>
> %solve
> >> s = solve(eq)
>
> s =
>
> 0
> (2^(1/2)*5^(1/2))/4
> (2^(1/2)*5^(1/2))/4
>
> %Take the second element for example
> >> s(2)
>
> ans =
>
> (2^(1/2)*5^(1/2))/4
>
> %square it if you like
> >> s(2)^2
>
> ans =
>
> 5/8
>
> Does this help?
>
> Alan Weiss
> MATLAB mathematical toolbox documentation
>
> Ender wrote:
> > I don't quite understand what you are saying here:
> >
> >> For s = solve(eq), you can take each solution and substitute lambda =
> >> 0 with the subs command to get your "variable."
> >
> > Also, MATLAB did not factor the equation in the form that I am looking
> > for. After typing in eq2 MATLAB outputs:
> >
> > eq2 =
> >
> > 1/8*lamda*(8*lamda^25)
> >
> > That is not the form that I am looking for. Also, whenever I type lamda
> > = 0 then type in any of my equations MATLAB does not give me the results
> > minus the lamda variable
> >
> > Ender
> >
> > Alan Weiss <aweiss@mathworks.com> wrote in message
> > <hlml7p$rgm$1@fred.mathworks.com>...
> >> Ender wrote:
> >> > I have a coding problem that I need help with.
> >> > > I am trying to write code that displays the value of a determinant
> >> with > eigen values but I need all the equation as simplified as
> >> possible then > I need MATLAB to store the value of the constant in
> >> that equation in a > variable.
> >> > > Here is my example:
> >> > > syms lamda
> >> > > % Make the identity matrix
> >> > Ident_matrix = lamda*eye(3);
> >> > > A = [0,.75,0;0.75,0,0.25;0,0.25,0];
> >> > > Result = AIdent_matrix;
> >> > > % Find the rho(Tj) value
> >> > > eq = det(Result)
> >> > > The form that I want is:
> >> > lamda*(lamda^20.625)
> >> > > Then I would like MATLAB to store the 0.625 in a variable.
> >> > > I am not sure where in the help menu to go to figure out how to do
> >> this. > Ender
> >>
> >> You are really close. See what happens with the following statements:
> >> s = solve(eq)
> >> and
> >> eq2 = factor(eq)
> >>
> >> For s = solve(eq), you can take each solution and substitute lambda =
> >> 0 with the subs command to get your "variable."
> >>
> >> Alan Weiss
> >> MATLAB mathematical toolbox documentation
Thanks, that worked, but know I have a slightly less complicated problem. I need to convert the result back into decimal form. I am using the value for "s" in another calculation however I would like to see the result of that calculation in decimal format. Here is my algorithm:
syms lamda
% Make the identity matrix
Ident_matrix = lamda*eye(3);
A = [0,.75,0;0.75,0,0.25;0,0.25,0];
Result = AIdent_matrix;
% Find the rho(Tj) value
eq = det(Result);
s = solve(eq)
s
rho = s(3)^2
% rho = str2num('s(3)^2')
%
omega =2/(1+sqrt(1(rho)^2))
I have tried "str2num" and "rats" however "str2num" gives me an empty matrix, and "rats" does not change the format. Is there a fraction to decimal command in MATLAB?
Ender
