how can i make a "for loop" which is like in Matl

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
pimkkk
Posts: 61
Joined: Wed Mar 03, 2010 11:55 pm
Location: bjut

how can i make a "for loop" which is like in Matl

Post by pimkkk »

i have a distribute lateral load apply on a column, and i have a fomular for this load which is related to H(the height of the column), my problem is how i can define the load and then apply it on the column, like how can i define the variable H, how can i make the loop?

Many thanks! :lol:
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

is this a tcl or c++ question?
pimkkk
Posts: 61
Joined: Wed Mar 03, 2010 11:55 pm
Location: bjut

Post by pimkkk »

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

Post by fmk »

use tcl for loop inside pattern command:

[code]
pattern Plain 1 "Linear" {
for {set i 3} {$i < 5} {incr i 1} {
load $i 0.0 [expr -$P] 0.0
}
}
[/code][/code]
pimkkk
Posts: 61
Joined: Wed Mar 03, 2010 11:55 pm
Location: bjut

Post by pimkkk »

thanks very much.

i am wondering that if i can make a "doble-for loop" in tcl, like i have two variables in the load function.

besides, do i need to make ten "for loop" if i devide this column into ten elements, cuz one of the variables is h(the height of the column)

thanks again!
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

yes .. you need to look into the tcl language.
pimkkk
Posts: 61
Joined: Wed Mar 03, 2010 11:55 pm
Location: bjut

Post by pimkkk »

hi, could you please let me know where i can get the recorder command within/for a foreach loop?

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

Post by fmk »

you can put the recorder command inside any loop!
pimkkk
Posts: 61
Joined: Wed Mar 03, 2010 11:55 pm
Location: bjut

Post by pimkkk »

but as you know, in foreach loop, i will get one result of the same element for each value of the variable, so how can i tell opensees to record these results, drift for example, which are based on different varible for the same element.
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

huh! .. you need to rephrase the question .. what exactly do you want.
pimkkk
Posts: 61
Joined: Wed Mar 03, 2010 11:55 pm
Location: bjut

Post by pimkkk »

um...i have a column, i divided it into 9 elements (10 nodes),this column is subjected to a random lateral distribute load, which is related to h (height of the node) and a (a variable whose value is 1, 2, 3, 4 respectively). Eventually, i want to get the drift of those 9 elements.

so when a=1, i will get one set of drift results of those 9 elements, and also when a=2, i will get another one set of results.

so my question is how i can tell opensees where to store these results for different a.

i use "for loop" for the h. and "foreach loop" for the a, but when i run the code, there is an error "extra characters after close-brace", so i thought maybe there is somthing wrong with the record.

Thank you very much!!!
pimkkk
Posts: 61
Joined: Wed Mar 03, 2010 11:55 pm
Location: bjut

Post by pimkkk »

i have fixed that brace error, and the new error is "wrong # argu: should be "foreach varList list ?varList list...?"

thanks again~
pimkkk
Posts: 61
Joined: Wed Mar 03, 2010 11:55 pm
Location: bjut

Post by pimkkk »

hi, i can now run the codes, but the results opensees gave me is still one set of results, like i only got one result when i have one a. but not the other results when a= other values.

so how can i get the other results???

Thanks a lot~
Dgroupsx
Posts: 1
Joined: Mon Apr 12, 2010 11:21 am
Location: United States of America
Contact:

how can i make a "for loop" which is like in Matl

Post by Dgroupsx »

Can anyone explain, how to use this function for my filteringselect dojo form element
Here my element:
keyword = new Zend_Dojo_Form_Element_FilteringSelectq;
keyword->setAutoCompletefalse
->setStoreIdkeywordId
->setStoreTypedojox.data.QueryReadStore
->setStoreParamsarrayurl=>/autocomplete/keywords
->setAttribsearchAttr, id
->setAttribhasDownArrow, false
->setAttribstyle, width:200px
->setAttriblabelType,html
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Post by fmk »

use the loop variable in recorder command.

[code]
foreach test {one two three} {

...
recorder node -file node2$test.out ...

...
}
[/code]
Post Reply