MATLAB Answers

How to write a structure variable in m file through another script?

10 views (last 30 days)
Partha Mitra
Partha Mitra on 28 Oct 2018
Commented: Stephen Cobeldick on 29 Oct 2018
How to write a structure variable in m file through another script? Eg. I want to write a structure like a.b.c in m file through script

  7 Comments

Show 4 older comments
Partha Mitra
Partha Mitra on 29 Oct 2018
Got the Solution myself. print as a string (Structures) into the *.m file.
If anyone has a better solution please let me know.
Stephen Cobeldick
Stephen Cobeldick on 29 Oct 2018
"If anyone has a better solution please let me know."
Convert to functions and pass the data as input/output arguments. This is "better" in the sense that it will be faster, will not impede the JIT engine, will be easier to debug, will allow memory management to handle the variables properly, and will be easier to understand. Printing strings in files is meta-programming, which is not recommended.
Functions are what experienced users use to write neat, efficient code. You should use them too.

Sign in to comment.

Answers (0)

Products


Release

R2010b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!