how to modify this code of loop.

1 次查看(过去 30 天)
J.FENG
J.FENG 2023-1-20
编辑: KSSV 2023-1-20
I am doing time series prediction with gaussian regression and get some problem with the code. In the code below, I am trying to do a prediction from today 18:00 until next day 24:00 every 3 hours.
(18-21-24-3-6-9-12-15-18-21-24)
In the code, the first step is to make a prediction of 21:00 from 18:00, so I write the code
case a>=3%21h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*0.9,1);
The next step is to make a prediciton of 24:00 based on the prediction value of 21:00 we get.
after that, I need to make a prediction of 3:00 based on the prediction value of 24:00 we get.
Then, I need to make a prediction of 6:00 based on the prediction value of 3:00 we get.
So I need keep on doing this way until next day 24:00
Anyone can help me how to modfiy the code ? thank you very much.
for i=3:3:30% prediction from today 18:00 to next day 24:00
ysd = zeros(30,1);
x_tmp(i,:) = wbgt_tmp(end+1-(input_time(end:-1:1)))';
[y_pred(i,1) ,ysd(i,1),yint] = predict(regressionGP, x_tmp(i,:),'Alpha',0.05);
y_tmp(i,1) = predict(linearModel, x_tmp(i,:)) ...
+ y_pred(i,1) + 0.5*ysd(i,1);
a=rem(i,30)
switch(1)
case a>=3%21h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*0.9,1);
case a>=6%24h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*0.7,1);
case a>=9%3h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*1.5,1);
case a>=12%6h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*1.8,1);
case a>=15%9h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)+ysd(i,1)*1.5,1);
case a>=18%12h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)+ysd(i,1)*1.4,1);
case a>=21%15h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*0.8,1);
case a>=24%18h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*0.9,1);
case a>=27%21h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*0.5,1);
case a>=0%24h
wbgt_tmp(end+1,1) = round(y_tmp(i,1)-ysd(i,1)*0.3,1);
end
end
wbgt_predict(:,month_days) = round(0.95*wbgt_tmp(end-23:end)+2.1);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by