how to get all the variables from a struct
1 view (last 30 days)
Show older comments
Hello,
I have a struct with 50 variables. the old code I get uses the variables directly, but I cannot access them so. for example, here is my struct "DATA" with a field "age", and the uses the variable "age" directly. newage=age+10 So to adjust the code, i need to use newage=DATA.age+10, and this can be done once (but not for 100 variables times and not when the variables is used 100 times in the code) So I look for a simple way to do this procedure. Can you help?
0 Comments
Accepted Answer
More Answers (1)
Walter Roberson
on 9 Feb 2018
If you only need the updated data, then adjust the data at the beginning of the code.
If you need both data, then at the beginning of the code, create a second struct containing the updated data and make the changes to your code to refer to the new name. You would not be able to do that automatically as you would need to make a decision at each point as to which of the two versions you needed, but the control-F replace-and-find can help a lot.
0 Comments
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!