Creating input file but replacing variables

1 次查看(过去 30 天)
Hello all,
I want to create input files in Matlab. All I need to do is to change some variables. As a result I want to change only some portions of the text or values and run them through loops. A portion of what I want is the following:
mdb.models[' Modelname- i '].sketches['__profile__'].rectangle(point1=(0.0, t_cover +( N -1)*( t_steel + t_int )+ t_steel ),
point2=( L , 2* t_cover +(N-1)*( t_steel + t_int )+ t_steel ))
So want the text above to be stacked i times and all the variables above (in bold) to be substituted with variables already defined (string for the Modelname variable and numeric values for the others).
Last step would be to save the created text into a .py file.
Thank you so much!

采纳的回答

Ganesh Gaonkar
Ganesh Gaonkar 2015-3-31
In general , when you have requirements which has combination of some texts with some variables which changes every i'th time, One of the way to get it done is by using 'eval' function inside your loop .You can find more details on this function here

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by