Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
undefined input argument of a user defined function

Subject: undefined input argument of a user defined function

From: anurag

Date: 27 Mar, 2013 13:50:08

Message: 1 of 3

i'm using the following code to create a function::

function [z]=maxtheta(A0,A1,h)
m=size(A0);
n=size(h);
t1=0;
for j=1:n(2);
    t2=t1+h(j);
     for i=1:m(1);
         a0=A0(i,j);
         a1=A1(i,j);
         z=feval(maxii,a0,a1,t1,t2);
     end
     t1=t1+t2;
end
end

where maxii is a function created by me and works fine with numerical values...now maxtheta suppose to take A0,A1,h as matrix inputs...but after defining A0,A1,h in command line when i am trying to run this function this is giving error message ::
input argument h is not defined, input argument a0(not A0) is not defined.....plzz help...i need it urgent

Subject: undefined input argument of a user defined function

From: someone

Date: 27 Mar, 2013 16:58:06

Message: 2 of 3

"anurag" wrote in message <kiuteg$mbe$1@newscl01ah.mathworks.com>...
> i'm using the following code to create a function::
>
> function [z]=maxtheta(A0,A1,h)
> m=size(A0);
> n=size(h);
> t1=0;
> for j=1:n(2);
> t2=t1+h(j);
> for i=1:m(1);
> a0=A0(i,j);
> a1=A1(i,j);
> z=feval(maxii,a0,a1,t1,t2);
> end
> t1=t1+t2;
> end
> end
>
> where maxii is a function created by me and works fine with numerical values...now maxtheta suppose to take A0,A1,h as matrix inputs...but after defining A0,A1,h in command line when i am trying to run this function this is giving error message ::
> input argument h is not defined, input argument a0(not A0) is not defined.....plzz help...i need it urgent

If you are getting an error saying that h is not defined, then I would first suggest looking at how you are calling maxtheta from your workspace or command line. Are you calling maxtheta with only two input arguments?

doc nargin
doc varargin

may help you.

Subject: undefined input argument of a user defined function

From: Tom Lane

Date: 27 Mar, 2013 17:16:12

Message: 3 of 3

> z=feval(maxii,a0,a1,t1,t2);
...
> where maxii is a function created by me and works fine with numerical
> values...now maxtheta suppose to take A0,A1,h as matrix inputs...but after
> defining A0,A1,h in command line when i am trying to run this function
> this is giving error message ::
> input argument h is not defined, input argument a0(not A0) is not
> defined.....plzz help...i need it urgent

This line will invoke maxii with no arguments, then run feval on the result.
I'm guessing you intended one of these instead:

   z=feval(@maxii,a0,a1,t1,t2);
   z=maxii(a0,a1,t1,t2);

-- Tom

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us