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 8819231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:18:13+00:00 2026-06-14T05:18:13+00:00

I’m writing a function that requires an input vector of dates which I specify

  • 0

I’m writing a function that requires an input vector of dates which I specify as Julian dates, and a range of values (as vectors). Within the function I use a pre-defined window size to remove any nans in the data. For example:

t = transpose(1/24:1/24:40);
data1 = 1+(30-1).*rand(length(t),1);
Randm = floor(1+(length(t)-1).*rand(120,1));
data1(Randm) = nan;
figure(1);
plot(data1,'linewidth',3);
hold on;

dailyData = reshape(data1,40,[]);
nanMap = isnan(dailyData);
validValuesPerDay = sum(~nanMap, 2);
nonNanData = dailyData;
nonNanData(nanMap) = 0;
sumPerDay = sum(nonNanData, 2);
dailyMeans = sumPerDay ./ validValuesPerDay;
dailyMeans = repmat(dailyMeans, [1 24]);
repairedData = dailyData;
repairedData(nanMap) = dailyMeans(nanMap);
data1 = reshape(repairedData,[],1);
plot(data1,'--r');

The problem that I’m faced with now is how to cope with data that is of different resolution to hourly e.g. daily, or weekly as this will effect the code when I use reshape. Does anyone have some suggestions on how to deal with this? I was thinking of doing something along the lines of specifying the window size (by this I mean when using reshape) as a fraction of the length of the data.

  • 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-14T05:18:14+00:00Added an answer on June 14, 2026 at 5:18 am

    Generally, you’d have to write separate routines for all different functionalities you want. For instance, what do you want do to if you get daily data? Average over weeks? Fortnights? Months? Years?

    Therefore, the most robust option would be (supposing you’ll always get linearly gridded times):

    switch t(2)-t(1)
        case 1/24 % hourly data
            dailyData = reshape(data1,[], 24);
            ... etc.
    
        case 1 % daily data
            weeklyData = reshape(data1,[], 7);
            ... etc.
    
        case 7  % weekly data
            yearlyData = reshape(data1,[], 52);
            ... etc.
    
        otherwise
            ... issue error
    
    end
    

    Note that the reshape is probably the only thing you need to do in the switch; the rest of the code will stay the same. You might want to re-think the variable names though…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

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.