フィルターのクリア

not enough input arguments (function created for vectors)

1 回表示 (過去 30 日間)
Apple
Apple 2017 年 2 月 8 日
編集済み: Stephen23 2017 年 2 月 8 日
I've created a script that creates 10 random vectors between 1 and 100 and the function I have below is supposed to count how many of each between certain values. however, when I run it from the editor it says not enough input values. also when I run it from the command windows it just says ans=0 rather than the 3 values it should give.
function[r1, r2, r3] = func22(vector)
r1=sum(vector>=1 & vector<=25);
r2=sum(vector>=25 & vector<=75);
r3=sum(vector>=75 & vector<=100);
any ideas of why it says no input values in editor and why it only gives one answer in the command window.

回答 (1 件)

Stephen23
Stephen23 2017 年 2 月 8 日
編集済み: Stephen23 2017 年 2 月 8 日
Do not click the green button. Call your function like this:
[r1,r2,r3] = func22(vector)
with an appropriate input argument and you will get three outputs, e.g.:
>> [out1,out2,out3] = func22(1:20:1e4)
out1 = 2
out2 = 2
out3 = 1
or whatever.
  2 件のコメント
Apple
Apple 2017 年 2 月 8 日
so to call a function with multiple outputs you need to put the outputs before it when you call it.
Stephen23
Stephen23 2017 年 2 月 8 日
編集済み: Stephen23 2017 年 2 月 8 日
Yes, this is what I just showed you, and this is exactly as the MATLAB introductory tutorials explain (you have done the introductory tutorials, I hope):
You should read this too:

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

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by