Import data from file inside "classdef properties"
古いコメントを表示
Hi all,
I'd like to understand how to do something that i find really intriguing.
I'm talking about importing data from an external file (Excel) and then assigning specific fields' values (from that file) to the variables defined within the "properties" of a "classdef" in my code. These variables are useful in different parts of the code, so that if I change the external file I can change the properties mentioned, which are automatically called inside the code itself.
I've already defined the parser for the external file, but I do not know how to integrate it into the classdef.
Your help would be greatly appreciated.
Thanks!
5 件のコメント
Jeff Miller
2024 年 3 月 13 日
Call your parser from the constructor when you create an object of the class? Maybe pass the file name to the constructor as an argument so that different objects will have properties taken from different Excel files...
Walter Roberson
2024 年 3 月 13 日
It depends: is it necessary that you be able to change the file while there are existing objects of the class? (If so then should the new properties affect the existing objects ?)
slow_hand
2024 年 3 月 13 日
Steven Lord
2024 年 3 月 13 日
Ideally, each time I run the code
What do you mean by "the code"?
- The class constructor?
- Each class method?
- Each file that accesses a property of the object?
What's the purpose of these properties? How do they get used in your workflow? Knowing a little more about your planned usage may help understand if there's an alternate approach that may be more efficient than your current planned approach. This may help avoid the XY problem.
slow_hand
2024 年 3 月 15 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Identification についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!