Prev: Converting Certain Data from Numeric Matrix to Text
Next: Turning off axis tick labels using Matlab code
From: Ali on 3 Jun 2010 17:38 Okay so I kind of figures it out! Here is the code I used: syms m1 m2 k1 k2 c1 c2 solve([(m2*k1)+(c2*c1)-73.6225, (k1*k2)-2.656e6, (m1*m2)-0.000575, (c2*m1)+ ((c2+c1)*m2)-0.01065, (m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-1.134625000000000e+02, (c2*k1)+(c1*k2)-604.5]); as you can see some of the numbers changed, this is due to some typing mistakes but either way... Since this is an exact solution the exact equations needed to be provided... Lets say I don't have the exact number (less digits lets say) so the exact solution really doesn't exist and we'll need to use some sort of iterative method? How would I go about doing that!?
From: Walter Roberson on 3 Jun 2010 18:08 Ali wrote: > Okay so I kind of figures it out! > Here is the code I used: > > syms m1 m2 k1 k2 c1 c2 > > > solve([(m2*k1)+(c2*c1)-73.6225, > (k1*k2)-2.656e6, > (m1*m2)-0.000575, > (c2*m1)+ ((c2+c1)*m2)-0.01065, > (m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-1.134625000000000e+02, > (c2*k1)+(c1*k2)-604.5]); > > > as you can see some of the numbers changed, this is due to some typing > mistakes but either way... Since this is an exact solution the exact > equations needed to be provided... Lets say I don't have the exact > number (less digits lets say) so the exact solution really doesn't exist > and we'll need to use some sort of iterative method? How would I go > about doing that!? solve() is still going to do the best job that can be done with the information you do have. About the only thing you could do better would be to do some interval arithmetic calculations to see the range of values that could be output based upon the precision of the input values. For example, you could add +T to the end of the last equation and solve for m1 m2 k1 k2 c1 c2, and then you would see how the solution changes. k1 turns out to be particularly sensitive -- e.g., a change of 4/100 in the 604.5 constant (i.e., would round to the same value) makes a difference of 3200 in k1. [{c1 = .1500000000, c2 = .1500000000, k1 = 3200., k2 = 830., m1 = .2500000000E-1, m2 = .2300000000E-1}, {c1 = -.1500000000, c2 = -.1500000000, k1 = -3200., k2 = -830., m1 = -.2500000000E-1, m2 = -.2300000000E-1}, {c1 = -3.078422704-29.01028502i, c2 = -.1070289711+1.152755637i, k1 = 8112.510827-1069.414581i, k2 = 321.8034898+42.42106441i, m1 = .1168663341-.1673147690E-1i, m2 = .4821328277E-2+.6902581763E-3i}, {c1 = 3.078422704+29.01028502i, c2 = .1070289711-1.152755637i, k1 = -8112.510827+1069.414581i, k2 = -321.8034898-42.42106441i, m1 = -.1168663341+.1673147690E-1i, m2 = -.4821328277E-2-.6902581763E-3i}, {c1 = -3.078422704+29.01028502i, c2 = -.1070289711-1.152755637i, k1 = 8112.510827+1069.414581i, k2 = 321.8034898-42.42106441i, m1 = .1168663341+.1673147690E-1i, m2 = .4821328277E-2-.6902581763E-3i}, {c1 = 3.078422704-29.01028502i, c2 = .1070289711+1.152755637i, k1 = -8112.510827-1069.414581i, k2 = -321.8034898+42.42106441i, m1 = -.1168663341-.1673147690E-1i, m2 = -.4821328277E-2+.6902581763E-3i}]
From: Steven Lord on 3 Jun 2010 21:55 "Ali " <sabti(a)mie.utoronto.ca> wrote in message news:hu97bs$rfm$1(a)fred.mathworks.com... > Okay so I kind of figures it out! > Here is the code I used: > > syms m1 m2 k1 k2 c1 c2 > > > solve([(m2*k1)+(c2*c1)-73.6225, > (k1*k2)-2.656e6, > (m1*m2)-0.000575, > (c2*m1)+ ((c2+c1)*m2)-0.01065, > (m1*k2)+ (k1*m2)+(k2*m2)+(c1*c2)-1.134625000000000e+02, > (c2*k1)+(c1*k2)-604.5]); That's quite a change from the equations you originally posted -- the value you subtracted from the last equation changed from 2.656e6 to -604.5. The fact that one of your values is still really large compared to the others could still cause problems -- either k1 or k2 have to be really large or they both need to be medium. When you combine that with the first and fifth equations, m1 and m2 are probably going to have to be fairly small, which means c1 and c2 will need to be large to counteract that in the fourth equation. Still, if you use OPTIMSET to increase the number of function evaluations allowed for FSOLVE, you can get reasonably small residuals after a few thousand iterations, which (due to the simplicity of the operations being performed) is farily quick -- a second or two. When I allow 2000 function evaluations, the residuals I receive are: fval = Columns 1 through 3 2.32177902148578e-006 -0.000115446280688047 -0.00133763329396516 Columns 4 through 6 0.011010895224216 3.9505012864538e-005 -2.60158685705392e-008 All but the residuals for 3 and 4 are close to 0, and even those resdiuals aren't that bad. -- 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
First
|
Prev
|
Pages: 1 2 Prev: Converting Certain Data from Numeric Matrix to Text Next: Turning off axis tick labels using Matlab code |