I want to type help function_name in the command window an the description should open
clear
function help = me(m)
help = 'generated numbers'
end

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 21 日
編集済み: Ameer Hamza 2020 年 10 月 21 日

0 投票

The simplest way is to add comments right after the first line
function help = me(m)
% generated numbers
% write your code
end
Then you can type
help me
and it will displayes
generated numbers
For a more detailed documentation, refer to this link: https://in.mathworks.com/help/matlab/matlab_prog/display-custom-documentation.html

3 件のコメント

Ervin DeBoy
Ervin DeBoy 2020 年 10 月 21 日
function [x1,x2] = dice(x)
%'This is a game of dice, you will receive 2 sets of outcomes, they are random generated numbers'
x1 = randi([1 6]);
x2 = randi([1 6]);
end
help function works, but how do i get 2 rolls?
Ameer Hamza
Ameer Hamza 2020 年 10 月 21 日
'x' is not used in your code, so you can define it like this
function [x1,x2] = dice() % <-- no 'x' needed here
%'This is a game of dice, you will receive 2 sets of outcomes, they are random generated numbers'
x1 = randi([1 6]);
x2 = randi([1 6]);
end
And call it like this
[x1, x2] = dice()
Ervin DeBoy
Ervin DeBoy 2020 年 10 月 21 日
Thank you for helping :)

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

その他の回答 (0 件)

カテゴリ

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

製品

タグ

質問済み:

2020 年 10 月 21 日

コメント済み:

2020 年 10 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by