Info

This question is closed. Reopen it to edit or answer.

Ideas on how to delete values in vector and later put them back into their right places?!

1 view (last 30 days)
Hello everyone,
I am trying to figure out the following problem and since I am new to matlab I don't know whether it can be solved at all... if you have any ideas or suggestions I would be very grateful.
My goal is to predict the next 24 hours of solar power feed-in based on the feed-in of the last 8760 hours (i.e. the last year) and a 24 hour solar radiation forecast. Actually I want to make several 24 hour predictions using a sliding window model. To make my prediction I want to use a model that was developed by some author and that is briefly described in one of his papers. He writes, that he only uses DAYLIGHT hours in his model.
So what I would like to do (but I do not know whether it's possible with matlab) is
1. to first delete all hours from my input vectors in which solar radiation is zero. This should be no problem.
2. Then I would use my model to estimate the solar power feed-in of the next 24 hours (well not exactly 24 hours, but as many hours as there are daylight hours during the forecast day)
3. Afterwards I need to put the previously deleted NIGHTTIME values back into place.
Because the length of days and nights shift over a full year, I can see several problems arising. A central one is the following: How can I tell matlab know where to put the previously deleted zeros (because of zero power feed-in during NIGHTTIME) in between the predicted values?
Thanks a lot for any ideas at all!!
  1 Comment
Stephen23
Stephen23 on 29 Sep 2014
Edited: Stephen23 on 29 Sep 2014
Keep your raw data as it is. No need to change it all the time, which is a slow process, and all that code is likely to be buggy and a pain to write... instead, whenever you require just a portion of the data, use indexing to extract the bits that you need.

Answers (1)

dpb
dpb on 28 Sep 2014
It's reasonably easily doable by simply keeping track from whence the values came when you removed them but I'd suggest "don't bother".
It'll be simpler to simply retain the full vector and select a working copy from it for each iteration. Once you've done the prediction with this set, reuse that variable for the next iteration. This will in all likelihood be quite a lot more efficient also instead of the multiple cases of shortening and the lengthening the original the other way. Each of those operations will cause a fair amount of allocation and reallocation to occur behind the scenes that there's no need to repeat.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!