I am creating a large test in which i will have common variables that will need to be shared between functions however I want the sizes and datatype of these variables to stay consistent throughout the test so that the data that i save is consistent. I was thinking of creating a function for data management that would define the size and type of each variable and would allow you to set and get the variables while performing all of the necessary checks to ensure nothing is accidentally not falling outside of the defined type and size. Is there an easier way to do this in matlab without manual checks?

 採用された回答

Adam
Adam 2015 年 5 月 7 日

1 投票

doc validateattributes
is very useful for validating sizes, data types, etc. I use it in almost every public function I write in both my usual OOP style and on the occasions I write just a good old-fashioned function.
A class is the ideal way for sharing data among different places with functions attached to that data also, but if you aren't familiar with OOP you might not want that learning curve. To be honest it isn't a big one - it took me less than 2 weeks to create my first OOP-based program having never looked at Matlab's OOP before so for something simpler it should be even quicker.

1 件のコメント

MasterCK
MasterCK 2015 年 5 月 7 日
That is exactly what i was looking for. Thank You

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSoftware Development についてさらに検索

製品

質問済み:

2015 年 5 月 7 日

コメント済み:

2015 年 5 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by