Prev: Converting Certain Data from Numeric Matrix to Text
Next: Turning off axis tick labels using Matlab code
From: Ali on 3 Jun 2010 15:32 Hello All, I have 6 non linear equations with 6 unknowns. I rewrote the equations to be in the form of f(x)=0 Then I tried this: [m1,m2,k1,k2,c1,c2]=solve('(m2*k1)+(c2*c1)-73.62','(k1*k2)-2.656e6','m1*m2-0.000575','(c2*m1)+ ((c2+c1)*m2)-0.01065','(m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-113.5','(c2*k1)+(c1*k2)-2.656e6') but i get weird complex number solutions. I know the exact solution for this paticular problem and it's suppose to be real . What am i doing wrong and what i can do to fix it! thank you for your time in advance,
From: Ali on 3 Jun 2010 16:03 I also tried: >> fsolve('myfun',[.15 0.15 830 3200 0.025 0.023]) function F=myfun(X) m1=X(1); m2=X(2); k1=X(3); k2=X(4); c1=X(5); c2=X(6); F(1)=(m2*k1)+(c2*c1)-73.62; F(2)=(k1*k2)-2.656e6; F(3)=m1*m2-0.000575; F(4)=(c2*m1)+ ((c2+c1)*m2)-0.01065; F(5)=(m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-113.5; F(6)=(c2*k1)+(c1*k2)-2.656e6; and even though that those guesses are the exact solution I still don't get the correct guesses from the fsolve function,, Help Please
From: Walter Roberson on 3 Jun 2010 16:03 Ali wrote: > I have 6 non linear equations with 6 unknowns. > I rewrote the equations to be in the form of f(x)=0 > Then I tried this: > > [m1,m2,k1,k2,c1,c2]=solve('(m2*k1)+(c2*c1)-73.62','(k1*k2)-2.656e6','m1*m2-0.000575','(c2*m1)+ > ((c2+c1)*m2)-0.01065','(m1*k2)+ > (k1*m2)+(k2*m2)+(c1*c2)-113.5','(c2*k1)+(c1*k2)-2.656e6') > > but i get weird complex number solutions. I know the exact solution for > this paticular problem and it's suppose to be real . What am i doing > wrong and what i can do to fix it! thank you for your time in advance, >> solve([(m2*k1)+(c2*c1)-73.62, (k1*k2)-2.656e6, m1*m2-0.000575, (c2*m1)+ ((c2+c1)*m2)-0.01065, (m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-113.5, (c2*k1)+(c1*k2)-2.656e6]); [{c1 = -101.6308814, c2 = 101.2824099, k1 = 26324.94465, k2 = 100.8928997, m1 =.1460092980E-2, m2 = .3938105368}, {c1 = 101.6308814, c2 = -101.2824099, k1 = -26324.94465, k2 = -100.8928997, m1 = -.1460092980E-2, m2 = -.3938105368}, {c1 = -.3980912853i, c2 = 184.9084814i, k1 = -.3981023190i, k2 = 6671651.667i, m1 = -.2398214657E-1i, m2 = .2397616904E-1i}, {c1 = .3980912853i, c2 = -184.9084814i, k1 = .3981023190i, k2 = -6671651.667i, m1 = .2398214657E-1i, m2 = -.2397616904E-1i}, {c1 = 101.2230983i, c2 = -101.6298681i, k1 = 26032.43125i, k2 = -102.0265827i, m1 = -.1465550364E-2i, m2 = .3923440738i}, {c1 = -101.2230983i, c2 = 101.6298681i, k1 = -26032.43125i, k2 = 102.0265827i, m1 = .1465550364E-2i, m2 = -.3923440738i}] Thus, there are _six_ exact solutions to the problem, two of which are real and negatives of each other (since you always have pairs of variables multiplied together, changing signs of everything results in the same numeric answer.) These six solutions are all valid within the constraints you provided. If you know that some of the variables are non-negative or are real, you can provide that information as a constraint by _not_ quoting the equations and using syms to create the variables with the 'real' or 'positive' option as appropriate.
From: Steven Lord on 3 Jun 2010 17:21 "Ali " <sabti(a)mie.utoronto.ca> wrote in message news:hu91pp$b7e$1(a)fred.mathworks.com... >I also tried: > > >>> fsolve('myfun',[.15 0.15 830 3200 0.025 0.023]) > > function F=myfun(X) > > m1=X(1); > m2=X(2); > k1=X(3); > k2=X(4); > c1=X(5); > c2=X(6); > > F(1)=(m2*k1)+(c2*c1)-73.62; > F(2)=(k1*k2)-2.656e6; > F(3)=m1*m2-0.000575; > F(4)=(c2*m1)+ ((c2+c1)*m2)-0.01065; > F(5)=(m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-113.5; > F(6)=(c2*k1)+(c1*k2)-2.656e6; > > > and even though that those guesses are the exact solution I still don't > get the correct guesses from the fsolve function,, You're mistaken that those guesses are the exact solution. When I simply evaluate the body of your function with the vector you passed into FSOLVE as X, only F(2) and F(4) were 0. Here's what I received for F: F = Columns 1 through 4 50.880575 0 0.021925 0 Columns 5 through 6 971.000575 -2655900.91 I'm guessing the wide range of orders of magnitude spanned by the numbers you're subtracting from your expressions [all the way from 0.000575 to 2.656e6] is probably contributing to the difficulties FSOLVE is having locate a solution to this system. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Ali on 3 Jun 2010 17:24 Thanks a lot for your reply. I tried to set them to positive and real but it states that there is no exact solution... and none of the solutions you provided were close to the exact solution. I don't know what really is happening here... The exact solution is suppose to be m1=0.025 m2=0.023 k1=3200 k2=830 c1=0.15 c2=0.15 here is what i tried: m1 = sym('m1','positive') m1 = sym('m1','real') m2 = sym('m1','positive') m2 = sym('m1','real') k1 = sym('m1','positive') k1 = sym('m1','real') k2 = sym('m1','positive') k2 = sym('m1','real') c1 = sym('m1','positive') c1 = sym('m1','real') solve([(m2*k1)+(c2*c1)-73.62, (k1*k2)-2.656e6, (m1*m2)-0.000575, (c2*m1)+ ((c2+c1)*m2)-0.01065, (m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-113.5, (c2*k1)+(c1*k2)-2.656e6]); I also tried: syms m1 m2 k1 k2 c1 c2 solve([(m2*k1)+(c2*c1)-73.62, (k1*k2)-2.656e6, (m1*m2)-0.000575, (c2*m1)+ ((c2+c1)*m2)-0.01065, (m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-113.5, (c2*k1)+(c1*k2)-2.656e6]); but none of them provided the exact solution noted above! Thank you for your time!
|
Next
|
Last
Pages: 1 2 Prev: Converting Certain Data from Numeric Matrix to Text Next: Turning off axis tick labels using Matlab code |