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 » Wed Mar 06, 2013 1:05 pm

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 » Thu Mar 21, 2013 7:32 pm

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 » Sat Mar 30, 2013 11:50 am

tank you ,
at tcl language please?


farzin rezazadeh
PhD candidate
Civil and Structural Engineering
Tehran University, IRAN

fmk
Site Admin
Posts: 5883
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: find maximum numaber of vector

Post by fmk » Mon Apr 01, 2013 2:52 pm

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 » Wed Apr 03, 2013 7:52 am

tank you dear

Post Reply