Effacer les filtres
Effacer les filtres

Creating input file but replacing variables

1 vue (au cours des 30 derniers jours)
Konstantinos Belivanis
Konstantinos Belivanis le 1 Mar 2015
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!

Réponse acceptée

Ganesh Gaonkar
Ganesh Gaonkar le 31 Mar 2015
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

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by