efficiency using struct.field vs variable
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Scope Variables and Generate Names dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!