Formula Mean Values in Matlab code.

Hello, can anyone help to write in Matlab code the formula below. The third term with the minus sine is a double sum.
(sum from i=1 to N of Xt-i*168)/N + (sum from j=1 to 7 of Xt-j*24)/7 -(sum of i=1 to n sum of j=1 to 7 of Xt-i*168-j*24)/(7*N).
thank you for your time

댓글 수: 4

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 29일
편집: Azzi Abdelmalek 2012년 9월 29일
what is Xt? its size?
aggelos
aggelos 2012년 9월 29일
편집: aggelos 2012년 9월 29일
hi, X it's a variable and t is the associated index. In the code below X is L.
Dear Azzi, My indexes for the sum's are i and j. t Stands for time . Xt is a time series of hourly spot electricity prices.
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 29일
what are your index i or t?
aggelos
aggelos 2012년 9월 29일
I have the code for a similar formula but i can;t understand it . Here it is. The formula is (sum from i=1 to N of Xt-i*7)/N + (sum from j=1 to 7 of Xt-j7)/7 -(sum of i=1 to n sum of j=1 to 7 of Xt-i*7-j)/(7*N). and the code is
mean(L(start+i-7:-7:start+i-N*7)) + ... mean(L(start+i-1:-1:start+i-7)) - mean(L(start+i-7-1:-1:start+i-(N+1)*7));

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2012년 9월 29일

0 개 추천

I don't think you've explained this correctly. What's the difference between t and i? Anyway, here's some code to get you started:
N = 100; % Or whatever. The number of elements.
T = 1 : N;
Xt = 2 * T; % Or whatever function of T that X is.
i = 1 : N;
theFirstSum = sum(Xt - (i * 168) / N)

댓글 수: 5

aggelos
aggelos 2012년 9월 29일
Thank you very much for tour time. Now I have to go , but i will try to correct it later.
aggelos
aggelos 2012년 9월 29일
As I said before Xt is a time series of electricity hurly prices. I need ths formula to break the time seris in two parts . a deterministic seasonal component which comes from this formula and a stochastic component ,which is the difference of the original time series minus the lagged series corresponding to the formula ineed to translate into matlab code.
Image Analyst
Image Analyst 2012년 9월 29일
OK. So, didn't I do that for the first sum? I just had to guess at Xt because you didn't tell us what it was - you replace that line with your actual Xt. Then you just basically do the same for the other sums. After all, it's your assignment so I can't just do everything for you and hand it over to you.
aggelos
aggelos 2012년 9월 30일
Dear Image Analyst, To make the things clear. Forget The 't' index.Let's say that X is my time series (L in the code above). My problem is how to define the indexes in each sum. For example, in the first sum the indexes are from i=1 to N , but i need to take values of the form : for i=1 I need to take the price which is 168 hours before. for i =2 the price which is 2*168=336 hours before ... for i=N the price which is N*168 hours before. Sorry to bother you and thank you very much for your time and interest.
To sum the prior 168 items, in general
theSum = zeros(1, lastIndex);
for k = 168 : lastIndex
theSum(k) = = sum(Xt((k - 167) : k));
end

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

태그

질문:

2012년 9월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by