From: "Josh Meyer" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Checking Values in a For/If loop
Date: Thu, 25 Apr 2013 09:04:57 -0400
Organization: MathWorks
Lines: 44
Message-ID: <klb9ls$ppj$>
References: <kl9s92$ptr$>
Reply-To: "Josh Meyer" <>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: 1366895100 26419 (25 Apr 2013 13:05:00 GMT)
NNTP-Posting-Date: Thu, 25 Apr 2013 13:05:00 +0000 (UTC)
In-Reply-To: <kl9s92$ptr$>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:794328

I can't tell what relation there is between your time(y) vector and the 
other, so I can't really include it here.

for i=2:length(th)
    if th(i)/th(i-1)==.1
        A(j) = i;
        j = j+1;

for ex, with
th = [100 10 1 0.5 0.25];
this loop returns
A =

     2     3

You may wish to preallocate A as a vector of zeros if you're dealing with a 
large number of checks.

"Mary " <> wrote in message 
> This is the jist of what I want to set up, I'm just fuzzy on how to go 
> about it:
> th(k)= vector of values [ko k1 k2 k3...]
> time(y) = time vector of values [t1 t2 t3]
> the vectors have equal lengths and are going to be plotted together
> for ( to cycle through all values of th(k));
> if  k1/ko == .1
> then stop code and show the value of k and y that was true for
> else
> continue cycling through each th(k) vector value until that becomes true 
> (example next cycle would check k2/k1 ==.1  etc)
> ko = initial value
> k1 = value right next to it
> I havent worked with vectors in forever and I would appreciate any help!
> Thanks!