Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
タイトルですべてが語られています。
多くのパラメーターを使用していた関数を変更して、これらすべてのパラメーターを内部に持つ構造のみを与えました。ここで、関数内のすべてを (param1 から struct.param1 に) 書き換えたくないので、関数全体が「struct.param1」から「param1」を取得できるようにする「using struct」のようなものを入れたいと思います。
これは明らかですか?英語は私の母国語ではありません。
そうする厄介な方法は
function my_using( params ) % % params should be a struct (NOT an array of struct!) % fn = fieldnames( params ); for ii = 1:numel( fn ) assignin('caller', fn{ii}, params.(fn) ); end
これで、関数を呼び出すことができmy_using、構造体のすべてのパラメーターが関数の変数として作成されます
my_using