Too many output arguments problem

I have a very simple too many output arguments problem but I could not fix this: I create a function whose name is myrand as
function myrand
a = 1+rand(3,4)*9
end
and I saved it. When I try to run myrand, there is no problem. However, I cannot use this function with other operators and cannot use it as an element for different functions. For example, when I assign b as b = myrand, then I encounter "too many output arguments" error. I am very appreciated if one help me for solution of this problem.

回答 (1 件)

per isakson
per isakson 2017 年 9 月 30 日
編集済み: per isakson 2017 年 9 月 30 日

1 投票

Replace
function myrand
a = 1+rand(3,4)*9
end
by
function a = myrand
a = 1+rand(3,4)*9;
end

2 件のコメント

Hadjer BEN BRAHIM
Hadjer BEN BRAHIM 2021 年 9 月 14 日
Didnt work for me ! Any help please ?
Walter Roberson
Walter Roberson 2021 年 9 月 15 日
Works for us.
b = myrand()
b = 3×4
1.4053 4.8161 7.2835 8.6531 4.9850 2.9053 6.9569 9.6011 6.5254 3.8004 6.6038 2.5618
function a = myrand
a = 1+rand(3,4)*9;
end

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

カテゴリ

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

質問済み:

2017 年 9 月 30 日

コメント済み:

2021 年 9 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by