Azzera filtri
Azzera filtri

Creating input file but replacing variables

1 visualizzazione (ultimi 30 giorni)
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!

Risposta accettata

Ganesh Gaonkar
Ganesh Gaonkar il 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

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by