efficiency using struct.field vs variable
Mostrar comentarios más antiguos
Hi, I am curious about the efficiency of using structure.field vs variable in function but I don't know how to search such particular question.
Basically I need to use a variable inside a function so I use structure to pass the information. Then inside the function, the variable will be used multiple times. So I can have two approaches. Every time I need the variable, I can either assign it to a variable at the start of the function, or use it from the structure. Two approaches in code provided below:
output=myfunction(mystruct)
Method 1:
myvariable=mystruct.myfield;
myvariable=myvariable*5/10+3...
Method 2:
mystruct.myfield=mystruct.myfield*5/10+3...
Not sure which one is faster if I got loads of use. Hope my question is clear.
Regards,
Ricky
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Scope Variables and Generate Names 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!