is it possible to overwrite an input variable?

Is this a possible or good solution? No problem with the following code?
function X = myfunc(a,b,c)
if nargin < 3
c = 42;
end
b = 137;
end

回答 (1 件)

Adam
Adam 2015 年 6 月 24 日
編集済み: Adam 2015 年 6 月 24 日

0 投票

There is no 'problem' with overwriting 'b' syntactically, it is 'possible'. The fact that 'X' never gets created is a problem though.
Is it a 'possible solution'? To what? Not to anything as far as I can see!
It isn't a good solution to anything though because there is no purpose in passing b into the function in the first place.

カテゴリ

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

質問済み:

2015 年 6 月 24 日

編集済み:

2015 年 6 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by