Slow execution of scripts
Mostrar comentarios más antiguos
Hi, I would appreciate if someone could help me out with this. I have a finite element code where I use properties of different materials. These properties are stored in a prop.m file like this:
___________________________
---------*prop.m*----------------
length=1*x; width=2.5*x; height=6.7*x^2; etc
________________________
Now inside the FE code, I need to call this script many times from inside other functions (F_n, n=function number) like run('./prop.m') to give me the properties at the "x" value. I have noticed that the code runs woefully slow when the properties are coded like this and runs much faster when the properties are hardcoded inside the functions. However, I have a lot of different functions that use the same properties and hardcoding it inside each function is not an option. I do realize that running a script is much slower than running a function. Is there a nice way to get the properties inside F_n without having to "run" a script?
One way I have thought of is passing an object from each function such that the parameters are properties of the object. So in F_n, I will use:
Obj=prop(x); length=Obj.length; width=Obj.width; height=Obj.height; etc.
Will this be any faster?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!