I am a new user of opensees and tcl language.
I am wondering how I can automatically get the length of a data vector, for example, an earthquake time history; therefore I can know how many steps to "analyze". Similar commands like last(file) in Matlab and rows(file) in MathCAD?
Many thanks.
How can I get the length of a data vector?
Moderators: silvia, selimgunay, Moderators
you have to load up the file into a list and then use: llength command.
www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104
Thanks Silvia. I made a proc to load the file into a list, and it works well.
proc EventLength filename {
set file [open $filename];
set iDstep [read $file];
set eventlist [list 0];
foreach Dstep $iDstep {
lappend eventlist $Dstep; };
set eventNo [llength $eventlist];
return [expr $eventNo-1];
}
proc EventLength filename {
set file [open $filename];
set iDstep [read $file];
set eventlist [list 0];
foreach Dstep $iDstep {
lappend eventlist $Dstep; };
set eventNo [llength $eventlist];
return [expr $eventNo-1];
}
Lijun