[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Newbie question solving lin sys

**From**: |
John B. Thoo |

**Subject**: |
Re: Newbie question solving lin sys |

**Date**: |
Fri, 27 Dec 2002 14:56:39 -0800 |

Bill---
Yowzer! Your suggestion worked perfectly.
octave:80> for s = [0:11]
> s.^[0:11] * x
> end
ans = 22
ans = 28.000
ans = 31.000
ans = 39.000
ans = 46.000
ans = 53.000
ans = 56.000
ans = 55.000
ans = 49.000
ans = 42.000
ans = 33.000
ans = 27.000

`I didn't realize there would be a loss of precision. (Not only am I new
``to Octave, but I'm also new to numerics in general.)
`
**Three follow-up questions. (I hope that you don't mind.)
1. What does the dot after the s in s.^[0:11] mean in the "for" loop?
2. What in the "for" loop tells Octave to add the terms?

`3. How do I plot the graph on [0:11] without a loss of precision? I
``tried this without success:
`

`octave:84> gplot [0:11] "x(1) + x(2)*x + x(3)*x**2 + x(4)*x**3 +
``x(5)*x**4 + x(6)*x**5 + x(7)*x**6 + x(8)*x**7 + x(9)*x**8 + x(10)*x**9 +
``x(11)*x**10 + x(12)*x**11"
` line 0: undefined function: x
Thanks for your patience.
---John.
On Friday, December 27, 2002, at 02:15 PM, William Lash wrote:

Whenever you type in the numbers for you calculation in s you are
losing precision. Instead of typing in:

octave:55> 22 + 129.32*s - 330.01*s**2 + 356.74*s**3 - 211.74*s**4 +

`77.512*s**5 - 18.446*s**6 + 2.9092*s**7 - 0.30191*s**8 +
``0.019818*s**9 -
`0.0007457*s**10 + 0.00001225*s**11

Try the following:
x(1)+x(2)*s+x(3)*s**2+x(4)*s**3+x(5)*s**4+x(6)*s**5+x(7)*s**6+x(8)*s**7+x(
9)*s**8+x(10)*s**9+x(11)*s**10+x(12)*s**11
There are better ways to write this in octave, one way is:
s.^[0:11] * x
and you could check all the values with a for loop:
for s = [0:11]
s.^[0:11] * x
end
Bill

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------