Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:04:34+00:00 2026-06-15T14:04:34+00:00

I have two time series: dat = [0,2,3,0,2,2,0,0,1,0.8,3,4,6,7,4,4,3,0,1,3,2.2,0]; dat2 = dat+.5; time = 1:length(dat);

  • 0

I have two time series:

dat = [0,2,3,0,2,2,0,0,1,0.8,3,4,6,7,4,4,3,0,1,3,2.2,0];
dat2 = dat+.5;
time = 1:length(dat);
plot(time,dat);
hold on;
plot(time,dat2,'r');

I would like to find the region in time that both vectors have the greatest successive number of values greater than one. So, for this particular example, both vectors have values greater than 1 between 10 and 18. However, they also have values greater than one on several other occasions. I can obtain the indices of the values greater than one by first generating a matrix:

data = [dat',dat2'];

And then using find

r1 = data>1;

This will provide me with the location of each value that is greater than one. Next I would like to find at what time (between which rows) are the values > 1 maintained for the longest duration. How can I achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:04:35+00:00Added an answer on June 15, 2026 at 2:04 pm

    To find the indices of the longest run of values, you can use the following code:

    dat = [0,2,3,0,2,2,0,0,1,0.8,3,4,6,7,4,4,3,0,1,3,2.2,0];
    
    id = find(dat>1);
    x = [0 cumsum(diff(id)~=1)];
    
    id(x==mode(x))
    

    This results in

    ans =
    
        11    12    13    14    15    16    17
    

    This code can be used with a matrix:

    dat = [0,2,3,0,2,2,0,0,1,0.8,3,4,6,7,4,4,3,0,1,3,2.2,0];
    dat2 = dat+.5;
    data = [dat',dat2'];
    
    id = find(all(data>1, 2));
    x = [0; cumsum(diff(id(:))~=1)];
    
    id(x==mode(x))
    

    This code gives the indices of the longest run of values greater than one in both columns:

    ans =
        11
        12
        13
        14
        15
        16
        17
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two multivariate time series x and y, both covering approximately the same
I have an irregular time series that I'm working with that I'd like to
I have a factored time series that looks like this: df <- data.frame(a=c(11-JUL-2004, 11-JUL-2005,
I have a time series of two indexes, with each row representing the closing
I have a function that creates time intervals between two time marks. The function
I have two images, both taken at the same time from the same detector.
I have a (C#) genetic program that uses financial time-series data and it's currently
I have two time series data frames: The first one: head(df1) : MSCI ACWI
I have two Lists that both are drag-drop enabled. I also draw a chart
I have two time series of data, one which is water temperature and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.