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

  • Home
  • SEARCH
  • 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 7891311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:35:11+00:00 2026-06-03T06:35:11+00:00

I am trying to grab the max for each year in my dataset. The

  • 0

I am trying to grab the max for each year in my dataset. The data is in one column, in order at a daily timestep.
How do I get the max from the first 365 rows, then from the next 365 rows?
I was thinking something like:

years=31;
for i=1:years
peak(i)=max(data(i:365*i,2))
end

but when i=2, the range should be from 366:730 and so forth.
The data matrix is 11322×7 double and I need column 2.

  • 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-03T06:35:12+00:00Added an answer on June 3, 2026 at 6:35 am

    I thought about suggesting something like @Thilo’s answer, but that doesn’t take into account leap years (which appear to show up in your data, since 365*31=11315, which is less than 11322)

    You might be able to gin up a complicated vectorized solution, but I’d be tempted to just manually keep track of the start and stop indices:

    NYEARS = 31;
    
    start = 1;
    stop = 365 + isLeapYear(year(1));
    n=1;
    maxValues = nan(NYEARS,1);
    while(n=<NYEARS)
      maxValues(n) = max(data(start:stop,2));
      n=n+1;
      start = stop + 1;
      stop = start + 365 + isLeapYear(year(n));
    end
    

    It’s probably not blazingly fast, but I doubt this is going to be a bottleneck either.

    function leap_p = isLeapYear(year)
      leap_p = ~mod(year,400) || (~mod(year,4) && mod(year,100)) 
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to grab a row that has the max of some column.
Im trying to grab all data(text) coming from a URL which is constantly sending
I'm trying to grab data with a special character (caron) from a database and
I'm trying to make a request using dojo.xhrGet to grab some XML data from
I'm trying to grab a single item from each of the Lists here, and
I am trying to grab all the td elements between the first two that
I have been trying to grab a file from an alternate git branch and
Hi I am trying to grab a div from another website using JS. I
I am trying to grab one or more table cells that contain a particular
I'm trying to grab a variable from an external file, but I need 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.