How can I define multiple named inputs for a function

2 ビュー (過去 30 日間)
Iagoba
Iagoba 2014 年 1 月 27 日
コメント済み: Iagoba 2014 年 1 月 27 日
This is exactly what I mean!!
The default function eye() admits multiple variables, something like varargin.
Other property is that it displays all the different possibilities!
If someone can help me, I'll be very grateful!
Thank you very much
Iagoba

回答 (1 件)

Amit
Amit 2014 年 1 月 27 日
  3 件のコメント
Amit
Amit 2014 年 1 月 27 日
If you want really a fancy tab completion, see this: http://undocumentedmatlab.com/blog/setting-desktop-tab-completions/
for a relatively simple one:
function a = myfunc(var1,var2,var3)
if nargin < 1
var1 = defaultvalueforvar1;
end
if nargin < 2
var2 = defaultvalueforvar1;
end
if nargin < 3
var3 = defaultvalueforvar1;
end
end
This will show tab completion for all 3 variable, however only 1 or less than 1 variable needed.
Iagoba
Iagoba 2014 年 1 月 27 日
Thanks!! It sounds good! I'll take a look.

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by