find maximum numaber of vector

If you have a script you think might be useful to others post it
here. Hopefully we will be able to get the most useful of these incorporated in the manuals.

Moderators: silvia, selimgunay, Moderators

Post Reply
farzinsiamak
Posts: 4
Joined: Wed Mar 06, 2013 12:48 pm

find maximum numaber of vector

Post by farzinsiamak »

how we can find the maximum number of a vector? which order?
thank you
linguan118
Posts: 140
Joined: Sun Oct 03, 2010 11:36 pm
Location: Hong Kong

Re: find maximum numaber of vector

Post by linguan118 »

tcl language or C++?
how about a loop
for (int i = 0; i < size(); i++)
if (x[i] < xMin)
xMin = x[i];
Research Assistant Professor, The Hong Kong Polytechnic University
guanlin@polyu.edu.hk
farzinsiamak
Posts: 4
Joined: Wed Mar 06, 2013 12:48 pm

Re: find maximum numaber of vector

Post by farzinsiamak »

tank you ,
at tcl language please?


farzin rezazadeh
PhD candidate
Civil and Structural Engineering
Tehran University, IRAN
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: find maximum numaber of vector

Post by fmk »

proc maxValue list {
set index 0
set maxindex $index
set maxval [lindex $list 0]
foreach val $list {
if {$val > $maxval} {
set maxindex $index
set maxval $val
}
incr index
}
return $maxval
}
farzinsiamak
Posts: 4
Joined: Wed Mar 06, 2013 12:48 pm

Re: find maximum numaber of vector

Post by farzinsiamak »

tank you dear
Post Reply