0

I am a newbie of matlab and am trying to define a pretty complex function to plot it. The content of file is following:

function [res] = distribution (input)
a = factorial(30)
b = factorial(input) * factorial(30-input)
c = power(0.05, input)
d = power(0.95, 30-input)

a/b*c*d
end

in the file named distribution with .m extension. But when I run it error returns: "Error using distribution (line 4). Not enough input arguments."

I read through the "Getting Started" and find no solution. Does anyone have suggestions on this?

1
  • 2
    how do you call your distribution function ? Commented Feb 21, 2016 at 7:57

1 Answer 1

3

The name of the single argument to your function distribution(..), namely argument input, conflicts with the existing native input command of Matlab,

input: Prompt for user input.

...

x = input(prompt)

Try choosing a different name of this argument (in example below: foo), and also remember to return your result by assigning it to the return variable res:

function res = distribution (foo)
    a = factorial(30);
    b = factorial(foo) * factorial(30-foo);
    c = power(0.05, foo);
    d = power(0.95, 30-foo);

    res = a/b*c*d; % <--- note, return parameter assignment
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.