

I have a (200:1) vector x1, and I want to find the maximal value in the vector. It seems like max(x1) should give me the max value, but no, it's not even close to the right answer from manual inspection. Hmmm. Maybe that's the index into the row vector where the max is stored? Although that makes no sense for a vector that isn't a row or column vector. Nope. That's wrong, too. Is Octave capable of telling me the max value stored in a vector? I've tried what the 'help' page says should work, but I think I just need to go buy Matlab.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On Wed, Feb 8, 2012 at 1:15 PM, Michael Davidson <[hidden email]> wrote:
I have a (200:1) vector x1, and I want to find the maximal value in the vector. It seems like max(x1) should give me the max value, but no, it's not even close to the right answer from manual inspection. Hmmm. Maybe that's the index into the row vector where the max is stored? Although that makes no sense for a vector that isn't a row or column vector. Nope. That's wrong, too. Is Octave capable of telling me the max value stored in a vector? I've tried what the 'help' page says should work, but I think I just need to go buy Matlab.
Works fine for me. What version of octave, on what OS? Could you provide a test case?
octave3.2.4.exe:24> x=rand(20,1)
x =
0.570176
0.908796
0.815253
0.437041
0.244348
0.840917
0.212318
0.019978
0.042693
0.551441
0.607535
0.701187
0.235667
0.456407
0.046169
0.366124
0.199947
0.174513
0.299213
0.532349
octave3.2.4.exe:25> max(x)
ans = 0.90880
Kind regards, Joanna
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


Thank you for the help. I apologize for the sassy question, but Octave problems were the straw that broke the camel's back on a bad day. It appears that this was a PEBCAK. On Tue, Feb 7, 2012 at 10:38 PM, Joanna Cheng <[hidden email]> wrote:
On Wed, Feb 8, 2012 at 1:15 PM, Michael Davidson <[hidden email]> wrote:
I have a (200:1) vector x1, and I want to find the maximal value in the vector. It seems like max(x1) should give me the max value, but no, it's not even close to the right answer from manual inspection. Hmmm. Maybe that's the index into the row vector where the max is stored? Although that makes no sense for a vector that isn't a row or column vector. Nope. That's wrong, too. Is Octave capable of telling me the max value stored in a vector? I've tried what the 'help' page says should work, but I think I just need to go buy Matlab.
Works fine for me. What version of octave, on what OS? Could you provide a test case?
octave3.2.4.exe:24> x=rand(20,1)
x =
0.570176
0.908796
0.815253
0.437041
0.244348
0.840917
0.212318
0.019978
0.042693
0.551441
0.607535
0.701187
0.235667
0.456407
0.046169
0.366124
0.199947
0.174513
0.299213
0.532349
octave3.2.4.exe:25> max(x)
ans = 0.90880
Kind regards, Joanna
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On Wednesday, February 08, 2012 07:45:42 am Michael Davidson wrote:
> Thank you for the help. I apologize for the sassy question, but Octave
> problems were the straw that broke the camel's back on a bad day. It
> appears that this was a PEBCAK.
>
> On Tue, Feb 7, 2012 at 10:38 PM, Joanna Cheng
< [hidden email]>wrote:
> > On Wed, Feb 8, 2012 at 1:15 PM, Michael Davidson
< [hidden email]>wrote:
> >> I have a (200:1) vector x1, and I want to find the maximal value in the
> >> vector. It seems like max(x1) should give me the max value, but no,
> >> it's not even close to the right answer from manual inspection. Hmmm.
> >> Maybe that's the index into the row vector where the max is stored?
> >> Although that makes no sense for a vector that isn't a row or column
> >> vector. Nope.
> >>
> >> That's wrong, too. Is Octave capable of telling me the max value
> >> stored
> >>
> >> in a vector? I've tried what the 'help' page says should work, but I
> >> think I just need to go buy Matlab.
> >
> > Works fine for me. What version of octave, on what OS? Could you provide
> > a test case?
> >
> > octave3.2.4.exe:24> x=rand(20,1)
> > x =
> >
> > 0.570176
> > 0.908796
> > 0.815253
> > 0.437041
> > 0.244348
> > 0.840917
> > 0.212318
> > 0.019978
> > 0.042693
> > 0.551441
> > 0.607535
> > 0.701187
> > 0.235667
> > 0.456407
> > 0.046169
> > 0.366124
> > 0.199947
> > 0.174513
> > 0.299213
> > 0.532349
> >
> > octave3.2.4.exe:25> max(x)
> > ans = 0.90880
> >
> > Kind regards,
> > Joanna
The values in your vector are printed using six decimal places. Your Octave
is set to display only five in its answers, the default. 0.908796, the second
entry above, rounds to 0.90880. Display one more place and you ought to see
the two as the same.
I hope Octave serves you well and that you stay with it.
Maynard Wright
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On Wednesday, February 08, 2012 07:45:42 am Michael Davidson wrote:
> Thank you for the help. I apologize for the sassy question, but Octave
> problems were the straw that broke the camel's back on a bad day. It
> appears that this was a PEBCAK.
No worries Michael, glad you got your problem resolved :) On Thu, Feb 9, 2012 at 5:46 AM, Maynard Wright <[hidden email]> wrote:
> On Tue, Feb 7, 2012 at 10:38 PM, Joanna Cheng
< [hidden email]>wrote:
> > octave3.2.4.exe:24> x=rand(20,1)
> > x =
> >
> > 0.570176
> > 0.908796
> > 0.815253
> > 0.437041
> > 0.244348
> > 0.840917
> > 0.212318
> > 0.019978
> > 0.042693
> > 0.551441
> > 0.607535
> > 0.701187
> > 0.235667
> > 0.456407
> > 0.046169
> > 0.366124
> > 0.199947
> > 0.174513
> > 0.299213
> > 0.532349
> >
> > octave3.2.4.exe:25> max(x)
> > ans = 0.90880
> >The values in your vector are printed using six decimal places. Your Octave
is set to display only five in its answers, the default. 0.908796, the second
entry above, rounds to 0.90880. Display one more place and you ought to see
the two as the same.
Thanks for pointing that out Maynard, I hadn't acually noticed! I wonder if this is a bug.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On Wednesday, February 08, 2012 12:46:00 pm Joanna Cheng wrote:
> > On Wednesday, February 08, 2012 07:45:42 am Michael Davidson wrote:
> > > Thank you for the help. I apologize for the sassy question, but Octave
> > > problems were the straw that broke the camel's back on a bad day. It
> > > appears that this was a PEBCAK.
>
> No worries Michael, glad you got your problem resolved :)
>
> On Thu, Feb 9, 2012 at 5:46 AM, Maynard Wright < [hidden email]>wrote:
> > > On Tue, Feb 7, 2012 at 10:38 PM, Joanna Cheng
> >
> > < [hidden email]>wrote:
> > > > octave3.2.4.exe:24> x=rand(20,1)
> > > > x =
> > > >
> > > > 0.570176
> > > > 0.908796
> > > > 0.815253
> > > > 0.437041
> > > > 0.244348
> > > > 0.840917
> > > > 0.212318
> > > > 0.019978
> > > > 0.042693
> > > > 0.551441
> > > > 0.607535
> > > > 0.701187
> > > > 0.235667
> > > > 0.456407
> > > > 0.046169
> > > > 0.366124
> > > > 0.199947
> > > > 0.174513
> > > > 0.299213
> > > > 0.532349
> > > >
> > > > octave3.2.4.exe:25> max(x)
> > > > ans = 0.90880
> > >
> > >The values in your vector are printed using six decimal places. Your
> >
> > Octave
> > is set to display only five in its answers, the default. 0.908796, the
> > second
> > entry above, rounds to 0.90880. Display one more place and you ought to
> > see
> > the two as the same.
>
> Thanks for pointing that out Maynard, I hadn't acually noticed! I wonder if
> this is a bug.
I wouldn't think of it as a bug. There are various ways to format the display
of your variables. Try
format long
and
format short
and after each,
x
max(x)
and you ought to see max(x) yielding the same precision as does x. I often
use printf() as it gives me control over the display that I'm used to using in
C.
Maynard
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave

