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:
find command in function file

Subject: find command in function file

From: Dhrue

Date: 15 Jul, 2009 03:24:04

Message: 1 of 5

function index = firm_size(r,w,z)
index=find(fl(r,w,z) < 10);
end
When I type firm_size(1,1,z_grid) (where z_grid is a known vector) I get the following error. ?? Subscript indices must either be real positive integers or logicals.

However when I type find(fl(1,1,z_grid) < 10) in the command window it works just fine. Please can anyone spot the error in my function file.
Thanks
Dhriti

Subject: find command in function file

From: Matt Fig

Date: 15 Jul, 2009 03:59:03

Message: 2 of 5

"Dhrue " <dhritiman-bhattacharya@uiowa.edu> wrote in message <h3ji4k$q71$1@fred.mathworks.com>...
> function index = firm_size(r,w,z)
> index=find(fl(r,w,z) < 10);
> end
> When I type firm_size(1,1,z_grid) (where z_grid is a known vector) I get the following error. ?? Subscript indices must either be real positive integers or logicals.
>
> However when I type find(fl(1,1,z_grid) < 10) in the command window it works just fine. Please can anyone spot the error in my function file.
> Thanks
> Dhriti



And fl is....

Subject: find command in function file

From: Dhrue

Date: 15 Jul, 2009 16:39:01

Message: 3 of 5

"Matt Fig" <spamanon@yahoo.com> wrote in message <h3jk67$4hb$1@fred.mathworks.com>...
> "Dhrue " <dhritiman-bhattacharya@uiowa.edu> wrote in message <h3ji4k$q71$1@fred.mathworks.com>...
> > function index = firm_size(r,w,z)
> > index=find(fl(r,w,z) < 10);
> > end
> > When I type firm_size(1,1,z_grid) (where z_grid is a known vector) I get the following error. ?? Subscript indices must either be real positive integers or logicals.
> >
> > However when I type find(fl(1,1,z_grid) < 10) in the command window it works just fine. Please can anyone spot the error in my function file.
> > Thanks
> > Dhriti
>
>
>
> And fl is....


Its another function file

Subject: find command in function file

From: us

Date: 15 Jul, 2009 16:56:03

Message: 4 of 5

"Dhrue " <dhritiman-bhattacharya@uiowa.edu> wrote in message <h3l0n5$k6i$1@fred.mathworks.com>...
> "Matt Fig" <spamanon@yahoo.com> wrote in message <h3jk67$4hb$1@fred.mathworks.com>...
> > "Dhrue " <dhritiman-bhattacharya@uiowa.edu> wrote in message <h3ji4k$q71$1@fred.mathworks.com>...
> > > function index = firm_size(r,w,z)
> > > index=find(fl(r,w,z) < 10);
> > > end
> > > When I type firm_size(1,1,z_grid) (where z_grid is a known vector) I get the following error. ?? Subscript indices must either be real positive integers or logicals.
> > >
> > > However when I type find(fl(1,1,z_grid) < 10) in the command window it works just fine. Please can anyone spot the error in my function file.
> > > Thanks
> > > Dhriti
> >
> >
> >
> > And fl is....
>
>
> Its another function file

well, it looks like you have a variable FL in your file...
do this:
- edit your function...
- set a break-point (dbstop) just before the call to FL...
- run your function...
- it stops...
- at the command prompt, type
     whos fl;
     which fl -all;
- look at the results

us

Subject: find command in function file

From: Matt Fig

Date: 15 Jul, 2009 17:08:03

Message: 5 of 5

Either that or the OP did something like this:

>>firm_size = firm_size(r,w,z);
>>firm_size = firm_size(r2,w2,z2); % z2 contains a zero or neg. num.
   ?? Subscript indices must either be real positive integers or logicals.

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