×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

??? input argument "n" is not defined

??? input argument "n" is not defined

??? input argument "n" is not defined

(OP)
Dear Friends
I have written Function f(n) in Matlab m-file and when I am trying to call f(n) (earlier writng n=1) Matlab tells me: "???input argument "n" is not defined"
Could any body help me?
best regards
zbik

My function looks like this
function g=f(n)
g=n+1

RE: ??? input argument "n" is not defined

1 – for troubleshooting, type n before you execute the function.  See if Matlab comes back with 1 to doublecheck whether Matlab is seeing the correct value of n.

2 – I’m not sure if it makes a difference to y our question, but I thought an end statement is required at the end of a function.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.

RE: ??? input argument "n" is not defined

Also I would try typing n=1 directly before the function and see if it works.  If it works there but doesn’t work within your program, then maybe you have a problem with variable scoping.  The variable n may have been defined in some function but is not available in the module that you are in now.  Look at the global statement and related matlab documention.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources