Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Jumping to the next interval

Subject: Jumping to the next interval

From: Archana Ananthanarayan

Date: 15 May, 2008 17:32:02

Message: 1 of 8

My problem goes like this :

I've a number line extending say from 0 to 600. I've divided
the line into equal intervals of 200 each. now i'm at 151 of
the 1st section. i need to jump to the next section say
number 201(of course - due to a condition), how do i
calculate the 1st number of the next interval? (that is 201)!

Thanks in Advance!

Subject: Re: Jumping to the next interval

From: helper

Date: 15 May, 2008 17:42:03

Message: 2 of 8

"Archana Ananthanarayan" <archana1985_ms@hotmail.com> wrote
in message <g0hs2i$ntm$1@fred.mathworks.com>...
> My problem goes like this :
>
> I've a number line extending say from 0 to 600. I've
divided
> the line into equal intervals of 200 each. now i'm at 151
of
> the 1st section. i need to jump to the next section say
> number 201(of course - due to a condition), how do i
> calculate the 1st number of the next interval? (that is
201)!
>
> Thanks in Advance!

First, if your line is from 0 to 600, you have 601 points,
not 600. So let's assume your line is from 1 to 600.

If you know your current point is cPt = 151, then you can
get the first point of the next section using:

firstNext = ceil((cPt-1)/200)*200 + 1

Note that I had to use (cPt-1) to handle the case where
cPt=200.


Subject: Re: Jumping to the next interval

From: Hosein

Date: 15 May, 2008 17:45:03

Message: 3 of 8

"Archana Ananthanarayan" <archana1985_ms@hotmail.com> wrote
in message <g0hs2i$ntm$1@fred.mathworks.com>...
> My problem goes like this :
>
> I've a number line extending say from 0 to 600. I've divided
> the line into equal intervals of 200 each. now i'm at 151 of
> the 1st section. i need to jump to the next section say
> number 201(of course - due to a condition), how do i
> calculate the 1st number of the next interval? (that is 201)!
>
> Thanks in Advance!

A=[.....] (1,600);
numcell(A); % (for example) =600
b=numcell(A)/number of lines
(line number)*b+1
I hope I understood your question rightly

Subject: Re: Jumping to the next interval

From: helper

Date: 15 May, 2008 17:54:02

Message: 4 of 8

> firstNext = ceil((cPt-1)/200)*200 + 1
>
> Note that I had to use (cPt-1) to handle the case where
> cPt=200.


Ooops. Looking at this again, I was wrong. No need to use
cPt-1

firstNext = ceil(cPt/200)*200 + 1

is sufficient.

Subject: Re: Jumping to the next interval

From: Archana Ananthanarayan

Date: 15 May, 2008 18:00:22

Message: 5 of 8

"helper " <spamless@nospam.com> wrote in message
<g0htbq$bhf$1@fred.mathworks.com>...
> > firstNext = ceil((cPt-1)/200)*200 + 1
> >
> > Note that I had to use (cPt-1) to handle the case where
> > cPt=200.
>
>
> Ooops. Looking at this again, I was wrong. No need to use
> cPt-1
>
> firstNext = ceil(cPt/200)*200 + 1
>
> is sufficient.


------------------------------------------------------------

thanks for all the replies! Its working!! Thanks a ton!

Subject: Re: Jumping to the next interval

From: Archana Ananthanarayan

Date: 16 May, 2008 11:04:02

Message: 6 of 8

"Archana Ananthanarayan" <archana1985_ms@hotmail.com> wrote
in message <g0htnm$4s9$1@fred.mathworks.com>...
> "helper " <spamless@nospam.com> wrote in message
> <g0htbq$bhf$1@fred.mathworks.com>...
> > > firstNext = ceil((cPt-1)/200)*200 + 1
> > >
> > > Note that I had to use (cPt-1) to handle the case where
> > > cPt=200.
> >
> >
> > Ooops. Looking at this again, I was wrong. No need to use
> > cPt-1
> >
> > firstNext = ceil(cPt/200)*200 + 1
> >
> > is
sufficie------------------------------------------------------------
>
> thanks for all the replies! Its working!! Thanks a ton!
>

-----------------------------------------------------------

The equation is not working when cPt assumes the values
150,250 etc.,

How to solve this?

Subject: Re: Jumping to the next interval

From: Nitin Chhabra

Date: 16 May, 2008 11:15:04

Message: 7 of 8

"Archana Ananthanarayan" <archana1985_ms@hotmail.com>
wrote in message <g0jpn2$p6n$1@fred.mathworks.com>...
> "Archana Ananthanarayan" <archana1985_ms@hotmail.com>
wrote
> in message <g0htnm$4s9$1@fred.mathworks.com>...
> > "helper " <spamless@nospam.com> wrote in message
> > <g0htbq$bhf$1@fred.mathworks.com>...
> > > > firstNext = ceil((cPt-1)/200)*200 + 1
> > > >
> > > > Note that I had to use (cPt-1) to handle the case
where
> > > > cPt=200.
> > >
> > >
> > > Ooops. Looking at this again, I was wrong. No need
to use
> > > cPt-1
> > >
> > > firstNext = ceil(cPt/200)*200 + 1
> > >
> > > is
> sufficie-------------------------------------------------
-----------
> >
> > thanks for all the replies! Its working!! Thanks a ton!
> >
>
> ---------------------------------------------------------
--
>
> The equation is not working when cPt assumes the values
> 150,250 etc.,
>
> How to solve this?
>
Hi,

what exactly is the problem ??
i checked for 150/250 etc and above gives correct
result....
Please tell the error message and result u get .

with reagrds,
Nitin

Subject: Re: Jumping to the next interval

From: Archana Ananthanarayan

Date: 16 May, 2008 11:29:02

Message: 8 of 8


> Hi,
>
> what exactly is the problem ??
> i checked for 150/250 etc and above gives correct
> result....
> Please tell the error message and result u get .
>
> with reagrds,
> Nitin
>
--------------------------------------------------------

Its working now!! i will get back when i encounter any
error. thanks!

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics