# understanding forecasting code in matlab

7 views (last 30 days)
NN on 26 Sep 2020
Commented: Raunak Gupta on 3 Oct 2020
Below is the code attached for cost , pv and load from matab example file.
Can i know what method is used for forecasting and how can i compare forecasted values and initial values by plotting it both ?what is the code for poltting and comparing?
Construct forecast vectors for optimization (N x M) matrix
for i = 1:N
CostMat(i,:) = C(i:i+M-1);
PpvMat(i,:) = clearPpvVec(i:i+M-1);
end
CostForecast.time = tvec;
CostForecast.signals.values = CostMat;
CostForecast.signals.dimensions = M;
PpvForecast.time = tvec;
PpvForecast.signals.values = PpvMat;
PpvForecast.signals.dimensions = M;

#### 1 Comment

Walter Roberson on 2 Oct 2020

Raunak Gupta on 2 Oct 2020
Hi,
The default method used by the optimoptions mentioned in the code is linprog which is to solve linear programming problems.
You can see it by creating an optimization problem and displaying the optimoptions property.
prob = optimproblem;
prob.optimoptions
In the file energyOptimizationscript.m, the last part is for plotting the forecasted output. Similarly, you may also plot input data which is being loaded in the very first line. battSolarOptimize function explains the exact setup of optimization problem.
Hope it clarifies!

NN on 2 Oct 2020
Thank you .But i hope no forecasting is done and it only replicates the data .Can you please make sure about the type of forecasting and how it is done .
Raunak Gupta on 3 Oct 2020
Hi,
Forecasting in essence means the same, like you want to predict the future data based on the past experience. So, the method by which the information is extracted from previous data is linear programming as mentioned in the answer. For the question of how, a model is fitted based on the data given and that model is used for generating output.
If the model is good in replicating then the forecasting will be good.
Hope this clarify the doubts!