From: Jeff Krampf on 4 May 2010 20:59 I'm having problems solving 2 equations simultaneously in matlab. I think the problem is the combination of sqrt's and squared variables. Its probably simple, but my programming knowledge is pretty limited, so any help would be appreciated. heres the simplified part of the program I'm trying to solve right now - ~~~~~~~~~~~~~~~~~~~~~ syms a b; T=pi/4; PE=.68; PA=.47; A = (a^2+b^2-2*a*cos(T)+cos(T)^2)/(a^2+b^2+2*a*cos(T)+cos(T)^2)-PE; B = PE*((a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2))/... (a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2)))-PA; solve(A,B,a,b); ~~~~~~~~~~~~~~~~~~~~~~ It returns Warning: Explicit solution could not be found. > In solve at 81 Anyone have any ideas to help, or a different solve function I could use? Thanks, Jeff
From: Walter Roberson on 4 May 2010 21:22 Jeff Krampf wrote: > I'm having problems solving 2 equations simultaneously in matlab. I > think the problem is the combination of sqrt's and squared variables. > Its probably simple, but my programming knowledge is pretty limited, so > any help would be appreciated. > > heres the simplified part of the program I'm trying to solve right now - > ~~~~~~~~~~~~~~~~~~~~~ > syms a b; > > T=pi/4; > PE=.68; > PA=.47; > > A = (a^2+b^2-2*a*cos(T)+cos(T)^2)/(a^2+b^2+2*a*cos(T)+cos(T)^2)-PE; > > B = PE*((a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2))/... > (a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2)))-PA; > > solve(A,B,a,b); > ~~~~~~~~~~~~~~~~~~~~~~ > > It returns Warning: Explicit solution could not be found. The numerator and denominator in your ()'d fraction in B are identical, so those terms simplify to exactly 1. Exactly 1 is arguably not correct for the case where a and b are both 0 and T is 0, as the expression would then be 0/0, but the simplifier ignores that singularity. With the term simplifying to exactly 1, B simplifies to PE-PA. As both of those are constants with known values, B simplifies to a constant. You then implicitly ask to solve for that constant (0.21) being equal to 0... which can never be the case. Thus you need to go back and find your error in the numerator or denominator for B so that the expression will still have at least one of 'a' or 'b'.
From: Jeff Krampf on 4 May 2010 21:45 Walter Roberson <roberson(a)hushmail.com> wrote in message <hrqh8f$9vr$1(a)canopus.cc.umanitoba.ca>... > Jeff Krampf wrote: > > I'm having problems solving 2 equations simultaneously in matlab. I > > think the problem is the combination of sqrt's and squared variables. > > Its probably simple, but my programming knowledge is pretty limited, so > > any help would be appreciated. > > > > heres the simplified part of the program I'm trying to solve right now - > > ~~~~~~~~~~~~~~~~~~~~~ > > syms a b; > > > > T=pi/4; > > PE=.68; > > PA=.47; > > > > A = (a^2+b^2-2*a*cos(T)+cos(T)^2)/(a^2+b^2+2*a*cos(T)+cos(T)^2)-PE; > > > > B = PE*((a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2))/... > > (a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2)))-PA; > > > > solve(A,B,a,b); > > ~~~~~~~~~~~~~~~~~~~~~~ > > > > It returns Warning: Explicit solution could not be found. > > The numerator and denominator in your ()'d fraction in B are identical, so > those terms simplify to exactly 1. Exactly 1 is arguably not correct for the > case where a and b are both 0 and T is 0, as the expression would then be 0/0, > but the simplifier ignores that singularity. > > With the term simplifying to exactly 1, B simplifies to PE-PA. As both of > those are constants with known values, B simplifies to a constant. You then > implicitly ask to solve for that constant (0.21) being equal to 0... which can > never be the case. > > Thus you need to go back and find your error in the numerator or denominator > for B so that the expression will still have at least one of 'a' or 'b'. sorry that was a type, the bottom should actually be a +, as follows- A = (a^2+b^2-2*a*cos(T)+cos(T)^2)/(a^2+b^2+2*a*cos(T)+cos(T)^2)-PE; B = PE*((a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2))/... (a^2+b^2+2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2)))-PA; but that still returns Warning: Explicit solution could not be found. > In solve at 81
From: Walter Roberson on 4 May 2010 22:02 Jeff Krampf wrote: >> > syms a b; >> > > T=pi/4; >> > PE=.68; >> > PA=.47; > A = (a^2+b^2-2*a*cos(T)+cos(T)^2)/(a^2+b^2+2*a*cos(T)+cos(T)^2)-PE; > > B = PE*((a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2))/... > (a^2+b^2+2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2)))-PA; > > but that still returns > Warning: Explicit solution could not be found. With that particular value of T, sin(T) and cos(T) are the same value. Your A thus simplifies to an expression of the form F(a,b)-PE and your B simplifies to an expression of the form PE*F(a,b)-PA . When you go to solve this pair of expressions together, we can read off of the implicit A=0 to see that F(a,b) = PE. Now substitute that into the implicit B=0, and we see that we get PE*PE-PA=0 . And since PA does not happen to be PE^2, there is no solution for this, no matter what F(a,b) actually is.
From: Jeff Krampf on 4 May 2010 22:15 Walter Roberson <roberson(a)hushmail.com> wrote in message <hrqjjh$ddu$1(a)canopus.cc.umanitoba.ca>... > Jeff Krampf wrote: > > >> > syms a b; > >> > > T=pi/4; > >> > PE=.68; > >> > PA=.47; > > > A = (a^2+b^2-2*a*cos(T)+cos(T)^2)/(a^2+b^2+2*a*cos(T)+cos(T)^2)-PE; > > > > B = PE*((a^2+b^2-2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2))/... > > (a^2+b^2+2*a*sin(T)*tan(T)+(sin(T)^2)*(tan(T)^2)))-PA; > > > > but that still returns > > Warning: Explicit solution could not be found. > > With that particular value of T, sin(T) and cos(T) are the same value. Your A > thus simplifies to an expression of the form F(a,b)-PE and your B simplifies > to an expression of the form PE*F(a,b)-PA . > > When you go to solve this pair of expressions together, we can read off of the > implicit A=0 to see that F(a,b) = PE. Now substitute that into the implicit > B=0, and we see that we get PE*PE-PA=0 . And since PA does not happen to be > PE^2, there is no solution for this, no matter what F(a,b) actually is. Oh haha that is something I never would have noticed. I picked pi/4 because it gives the most fluctuation for experimental values the code is based on but I should have thought about what it did to the math. Thank you very much. Now I've got a question that really shows how little matlab experience I have, my output arrays like : (7365200837329^(1/2)/10445874 + 4916269503883/18186047270646)^(1/2) (7365200837329^(1/2)/10445874 + 4916269503883/18186047270646)^(1/2) (4916269503883/18186047270646 - 7365200837329^(1/2)/10445874)^(1/2) -(1/10445874*7365200837329^(1/2) + 4916269503883/18186047270646)^(1/2) (4916269503883/18186047270646 - 7365200837329^(1/2)/10445874)^(1/2) -(1/10445874*7365200837329^(1/2) + 4916269503883/18186047270646)^(1/2) -(4916269503883/18186047270646 - 1/10445874*7365200837329^(1/2))^(1/2) -(4916269503883/18186047270646 - 1/10445874*7365200837329^(1/2))^(1/2) is there any way to make it display the numbers as simple decimal numbers, and also, is there anyway to make it only display positive values since those are the ones I am interested in?
|
Next
|
Last
Pages: 1 2 3 Prev: export a cell of strings as a text file Next: Windows 7 Installation Problem |