Results 1 to 4 of 4

Math Help - MatLab Help for Beginner

  1. #1
    Newbie
    Joined
    Jun 2008
    Posts
    4

    MatLab Help for Beginner

    Hello

    I'd appreciate any help or recommendations I can get for my problem.

    The basic problem:

    I have a large column of data and I would like to evaluate when data in the column becomes less than predetermined value (this I can do). However the second part of this requires the data to be less than the predetermined value for a specified period of time (or number of cells) or it does not get considered.

    Make sense?

    Does anyone have suggestions?

    Thanks in advance!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by rancediddy View Post
    Hello

    I'd appreciate any help or recommendations I can get for my problem.

    The basic problem:

    I have a large column of data and I would like to evaluate when data in the column becomes less than predetermined value (this I can do). However the second part of this requires the data to be less than the predetermined value for a specified period of time (or number of cells) or it does not get considered.

    Make sense?

    Does anyone have suggestions?

    Thanks in advance!
    There is more than one way to skin this cat but this is one way:

    Code:
    --> data=rand(20,1)
    data =
    0.5322
    0.2064
    0.7200
    0.0361
    0.1283
    0.3153
    0.1913
    0.9270
    0.4376
    0.5417
    0.6870
    0.5197
    0.4237
    0.2228
    0.7730
    0.5879
    0.9323
    0.7247
    0.6626
    0.5490
    --> bdata=data>0.25
    bdata =
    1
    0
    1
    0
    0
    1
    0
    1
    1
    1
    1
    1
    1
    0
    1
    1
    1
    1
    1
    1
    --> delta=bdata(1:length(bdata)-1)- bdata(2:length(bdata))
    delta =
    1
    -1
    1
    0
    -1
    1
    -1
    0
    0
    0
    0
    0
    1
    -1
    0
    0
    0
    0
    0
    --> dd=(delta==0)
    dd =
    0
    0
    0
    1
    0
    0
    0
    1
    1
    1
    1
    1
    0
    0
    1
    1
    1
    1
    1
    --> ii=[1:length(dd)]';
    --> zz=nonzeros(dd.*ii)
    zz =
    4
    8
    9
    10
    11
    12
    15
    16
    17
    18
    19
    The values in zz are indices into the data matrix of elements that are less than the threshold and also the next element is less than the threshold.

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jun 2008
    Posts
    4
    I really appreciate the help. However, I am having trouble following what you indicated.

    Perhaps I should have explained myself a little better. Or maybe what you suggested does work....I just can't follow. If so I apologize in advance and will not waste more of your time!

    So - in an attempt to make this a little clearer - I have a large column of data and I would like to evaluate when the data becomes less than a predetermined value(this I can do).

    I believe the second part of my problem may not have been clear the last time - The second part of this requires the data to be less than the predetermined value (in your example it was greater than .25 - that's fine), however I would like to specify that there has to be, for example, 3 consecutive data points greater than the .25 criteria, for it to 'count' or be considered for further analysis.

    Again.....my apologies if this is indeed what the above code does....and I will not waste your time further.

    Thanks kindly for your help!
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by rancediddy View Post
    I really appreciate the help. However, I am having trouble following what you indicated.

    Perhaps I should have explained myself a little better. Or maybe what you suggested does work....I just can't follow. If so I apologize in advance and will not waste more of your time!

    So - in an attempt to make this a little clearer - I have a large column of data and I would like to evaluate when the data becomes less than a predetermined value(this I can do).

    I believe the second part of my problem may not have been clear the last time - The second part of this requires the data to be less than the predetermined value (in your example it was greater than .25 - that's fine), however I would like to specify that there has to be, for example, 3 consecutive data points greater than the .25 criteria, for it to 'count' or be considered for further analysis.

    Again.....my apologies if this is indeed what the above code does....and I will not waste your time further.

    Thanks kindly for your help!
    Well there are a couple of approaches to this problem, you can use the same technique as above on dd as was used on ddata, recursivly for as many times as number of samples less than the threshols as desired, or you can write a loop counting 1's in bdata.

    Something like:

    Code:
    ll=length(bdata);
    rv=[];
    for idx=1:ll
      if bdata(idx)==1
        n1s=0;
        for jdx=1 to ncross-1
          if bdata(idx+jdx) ~= 1
            break;
          else
            n1s=n1s+1;
          end
        end
        if n1s==ncross
          rv=[rv,n1s];
        end
      end
    end
    (warning untested code)

    RonL
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. integration (beginner)
    Posted in the Calculus Forum
    Replies: 9
    Last Post: May 12th 2009, 04:41 PM
  2. STATA beginner
    Posted in the Math Software Forum
    Replies: 0
    Last Post: January 4th 2009, 06:37 PM
  3. Beginner to mathematica
    Posted in the Math Software Forum
    Replies: 8
    Last Post: November 13th 2008, 02:39 PM
  4. Need help on beginner algebra for exam!
    Posted in the Algebra Forum
    Replies: 3
    Last Post: March 13th 2008, 09:36 PM
  5. Stuck... beginner
    Posted in the Calculus Forum
    Replies: 1
    Last Post: June 13th 2006, 05:26 PM

Search Tags


/mathhelpforum @mathhelpforum