From: Nathan on
On Mar 22, 5:38 pm, "J Bell" <superblind...(a)gmail.com> wrote:
> "Oleg Komarov" <oleg.komarovRemove.t...(a)hotmail.it> wrote in message <ho922l$t3...(a)fred.mathworks.com>...
> > > when I run it, I get the message
>
> > > ??? Input argument "Y" is undefined.
>
> > > Error in ==> dumb at 3
> > > err=Y-X*beta;
>
> > > any help?
>
> > > thanks
>
> > > why does this error message appear in general?  
>
> > Be more precise, how do you run it?
>
> > It appears whenewer you try to use a variable that doesn't exist yet in the workspace.
>
> > An example:
> > clear
> > a = 1+c;
>
> > Oleg
>
> I saved an m file with the name "dumb.m" containing this code, and in Matlab navigated to the location of this m file so that it appears in the "Current Directory" window.  I run it by typing "dumb" and pressing enter in the command window.  Perhaps this is the problem?

That is the problem.

What value would you expect to be in Y, X, or beta, if you don't tell
the program what values they are supposed to be?

If that is the extent of your function, try typing this in the matlab
command window:
%arbitrary data values:
Y = 5;
beta = .01;
X = 4;
%function call
dumb(beta,Y,X)


-Nathan

From: J Bell on
Nathan <ngreco32(a)gmail.com> wrote in message <cd8c0f96-ec6b-47bc-8c0c-2d8b4dd441cb(a)d30g2000prn.googlegroups.com>...
> On Mar 22, 5:38 pm, "J Bell" <superblind...(a)gmail.com> wrote:
> > "Oleg Komarov" <oleg.komarovRemove.t...(a)hotmail.it> wrote in message <ho922l$t3...(a)fred.mathworks.com>...
> > > > when I run it, I get the message
> >
> > > > ??? Input argument "Y" is undefined.
> >
> > > > Error in ==> dumb at 3
> > > > err=Y-X*beta;
> >
> > > > any help?
> >
> > > > thanks
> >
> > > > why does this error message appear in general?  
> >
> > > Be more precise, how do you run it?
> >
> > > It appears whenewer you try to use a variable that doesn't exist yet in the workspace.
> >
> > > An example:
> > > clear
> > > a = 1+c;
> >
> > > Oleg
> >
> > I saved an m file with the name "dumb.m" containing this code, and in Matlab navigated to the location of this m file so that it appears in the "Current Directory" window.  I run it by typing "dumb" and pressing enter in the command window.  Perhaps this is the problem?
>
> That is the problem.
>
> What value would you expect to be in Y, X, or beta, if you don't tell
> the program what values they are supposed to be?
>
> If that is the extent of your function, try typing this in the matlab
> command window:
> %arbitrary data values:
> Y = 5;
> beta = .01;
> X = 4;
> %function call
> dumb(beta,Y,X)
>
>
> -Nathan

I made this very cumbersome by not including the other code, that which defines the variables, sorry, here it is:

beta=[1;0];
X=[ones(N,1) rand(N,1)];
mu=randn(N,1);
Y=X*beta+mu;

So Y is defined here. I should have included this before, sorry.
So the variable "Y" appears in the workspace with the value listed as "<500x1 double>"

After running this in the command window, I still get the error message.
From: Matt Fig on
Type this, then hit return:

>>docsearch('function syntax')

then read it all.
From: Walter Roberson on
J Bell wrote:

> I made this very cumbersome by not including the other code, that which
> defines the variables, sorry, here it is:
>
> beta=[1;0];
> X=[ones(N,1) rand(N,1)];
> mu=randn(N,1);
> Y=X*beta+mu;
>
> So Y is defined here. I should have included this before, sorry.
> So the variable "Y" appears in the workspace with the value listed as
> "<500x1 double>"

Yup, but that's in the "base workspace" that it is defined, not in the
workspace of your function.

A variable name in your function need not have a single thing to do with
a similar variable name in the base workspace or in the calling
function. The content of the 'Y' variable in your function is determined
entirely by the _value_ of what you pass to the function in the
corresponding argument *position*.

Just do like an earlier poster suggested, and invoke the function from
the command window, e.g.,

dumb(beta,Y,X)

That would take the _value_ of beta from the current workspace and make
it available to the function 'dumb' under whatever name you listed first
in the arguments in the 'function' statement.
From: Sadik on
Hi,

The problem could well be that you have more than one dumb.m's...

Please type the following in the command window:

which -all dumb

This is going to give you the list of all different dumb.m's under different folders.

One solution to your problem could be to go directly to the folder in which your three-input dumb.m resides [the one with syntax dumb(beta,Y,X)].

And the bottom line is that we should never write two or more functions with the same name. :-) [Of course, if that is the case...]

Best.
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: mex command
Next: Hessian matrix for Image Analysis