Borrar filtros
Borrar filtros

Creating input file but replacing variables

1 visualización (últimos 30 días)
Konstantinos Belivanis
Konstantinos Belivanis el 1 de Mzo. de 2015
Respondida: Ganesh Gaonkar el 31 de Mzo. de 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!

Respuesta aceptada

Ganesh Gaonkar
Ganesh Gaonkar el 31 de Mzo. de 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

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by