creating function that will accept input argument and return out argument

how to Create a function called square() which will accept one input argument and return the squared value of the input argument as an output argument (result)

回答 (2 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 6 月 5 日
function OUT = SQUARE(a)
OUT = a.^2;
end

2 件のコメント

Walter Roberson
Walter Roberson 2021 年 6 月 5 日
... it was a homework question (I have seen it before.)
On the other hand, it is such a simple homework question that it is difficult to resist just giving the solution.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 6 月 5 日
@Walter: I will take a note on this issue. You are right on hw assignments. Thanks.

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

MCEBISI SIBISI
MCEBISI SIBISI 2021 年 11 月 21 日
OUT = 2.^2
OUT = 4

1 件のコメント

DGM
DGM 2021 年 11 月 21 日
That's not a function. How does this answer the question?

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

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

2021 年 6 月 5 日

コメント済み:

DGM
2021 年 11 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by