efficiency using struct.field vs variable
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Scope Variables and Generate Names finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!