File Exchange

image thumbnail

Time Series Analysis and Forecast

version 1.3 (160 KB) by Iman
TSAF enables you to quickly analyze time series and forecast the future.


Updated 12 Aug 2018

View Version History

View License

How to open the GUI:
Step 1) download and unzip the package.
Step 2) copy all the files & folders included in the unzipped package into the current working directory of Matlab*.
* To find out the current working directory, please type "pwd" in the Matlab command line.
Step 3) Type "TSAF" in the command line.
Step 4) Enjoy it!
Please watch the following short tutorials to quickly learn the topic and master the GUI:
Tutorial 1 - Concept:
Tutorial 2 - Trend and Seasonality:
Tutorial 3 - ARMA:
Tutorial 4 - TSAF (Example 1) :
Tutorial 5 - TSAF (Example 2) :
Tutorial 6 - TSAF (Example 3)
Tutorial 7 - TSAF (New Feature)
Please subscribe to my signal processing channel to see more tutorials:

This GUI is developed for 2060 Project at the Institute for Integrated Energy Systems at the University of Victoria, Canada. The project has been funded by Pacific Institute for Climate Solutions, Natural Resources Canada and Natural Sciences and Engineering Research Council of Canada. This funding is gratefully acknowledged.

[1] Peter J. Brockwell, Richard A. Davis, "Introduction to Time Series and Forecasting", Second Edition, Springer, 2002.
[2] Chris Chatfield, "Time-Series Forecasting", Chapman &C Hall/CRC, 2000.


"Photos courtesy of and copyright Free Range Stock,"

Cite As

Iman (2021). Time Series Analysis and Forecast (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (83)

JAime carrasco

Khaled Benaggoune

Abolfazl Nejatian

dear Iman,
this is a very nicely written code and thank you for sharing the tutorial video about time series prediction.

i have written a time series prediction code with CNN, LSTM, and MLP networks.

you can visit it from my Mathworks account at the link below.

Valeri Disko

Robert Keane

mina golshan

Thank you for this perfect TSAF. I have one specific question. would you please let me know how is possible to upload online variation of data? I mean how to link them?

jose saballos

Dear Iman, when I run the "Batch Fit" I always get the following error message: "BIC.xls file is open, please close it now"

It is impossible to get rid of that error, and I don't have any XLS file open. I'm using R2016b version of MatLab.
How can I solve that issue?


Hi all. Thanks a lot for your feedback and messages and I apologize for some error messages that some of you are getting. I believe that's a consistency issue which is very common in different versions of MATLAB and also between different operating systems. I suggest to use the error message to find out which line goes wrong. Then, find the equivalent command for your MATLAB version/OS. For example, I know "xlsread" command is supported only on Windows computers with Excel software. Of course I didn't know this back then when developing software otherwise I would come up with something more general such as "readtable". I wish I had time to work on TEMS to build something more robust but currently my life has been very hectic. If you are interested to help me building a better "TEMS", please send an email to


Hi Iman, Such a great work! But can you help me with the error box I'm getting. My Forecast.xls is not opening and giving me error box. My email Id is
Thank you.


Samaa Al-Khrisha

Thank you for the tutorials, I really enjoyed them, but I cannot import my data, I'm using RMatlab17a. Is there any solution for that?

mena hamoum

Hi Iman
thanks for such a great TSAF, easy to use
i hope that you can help me : i'm using this package to estimate the solar radiation using historic data ranges since, 2010 till 2017 of six stations. my probleme is when i import my data i have nothing in frequency window... is this normal??
thank you in advance

Omid Reihany

Great work:)
I found one flaw.
The "q" in the result of Batch fit can't be seen in the pop-up, please change the pop-up menu size.


Could anybody tell where the excel sheet containing forecasting samples are stored after Forecasting by the GUI

Nurkholis Hakim



Hi Bushra, thanks a lot for your positive feedback. You need econometric toolbox to work with TSAF. I suggest to download the trial version as it is free for one month.

bushra raza

i enjoyed learning through your tutorials. thanx a lot.
i tried your TSAF but when i run this on Matlab Command window, i got the error dialog " TSAF recquired econometric toolbox. i am using Matlab R2017b.

i have univariate time series data of Water levels of different stations. historic data ranges since,1985 till 2017.
please guide me would this TSAF work for my data sets. and should i download econometric toolbox . is it free ?

Mrs. Aamir


Hi Fred. Could your please email your data file to me? I will resolve the issue asap. My email is


Hi Iman,
I'm wandering if you have solved data importing issue with RMatlab17a or not?
I cannot import any data other than your example data.


Sorry for the trouble! Please describe the issue or "print screen" the error and email it to

Md Munir Hayet Khan

I am also facing the same problem. It is not possible to Import data in Matlab 2017a.

Alessio Cariboni

Hi Iman, using MATLAB R2017b the "import data" section is not visible, maybe some compatibily issue. Can U help me? Thank a lot


Hi Gaby, Thank you for the feedback and sorry to hear that you are not happy with my code. Please keep in mind that my toolbox is not doing any magic. It basically uses some simple concepts to see if there is any trend or periodic behavior in data and fit data to an ARIMA(p,q) model based on (partial) autocorrelation. I don't know why you get such a large error. One possible reason might be that you didn't choose a good model or your data is basically so non-stationary. Please note that it is NECESSARY to have a stationary process. That's why we need to remove trend and seasonality first and hopefully what remains has some stationary characteristics. Hope this makes sense and sorry again for the trouble.

Gaby Bou Tayeh

Three stars for the hard work and tutorial, however, the forecasting accuracy is very terrible. The produced error is ridiculously high.

Hello Imaan, I cannot display the full window of TSAF.fig using MATLAB 2017a. The import data section is gone due to the over size of the figure and I can't minimize or adjust the size of the window. Can you help me out? Thank you.

John Callahan

Matthias Ho

Good job Iman!
I have watched tutorial 5 and need some explanation on the graph of amplitude response vs freq.

How did you generate amp/freq based on the data/signal chart? Seems like the amplitude response is in the order of 7x10^5.
The concept of harmonic is not explained prior
The rest of acf/pacf explanation is very clear.

David Cheung

I cant download the econometrics toolbox. please help. thanks


@Vijay: what is your MATLAB version? I guess you have compatibility issue.
@Durgesh: can you please take a screenshot and email it to me? I need to see the settings that you use in other boxes.
@Will: thank you ;)

Will Huang

very good introduction and tools, thanks a lot!

durgesh singh

Hi Iman, Thanks for the script and excellent demo. I am getting an error while I am clicking the estimate button. The error message is "Lags and Coefficients vectors must have the same length! ".

Vijay Waghmare

Hi Iman, Thanks for wonderful GUI. Could you please help me with below error for importing the file.>@(hObject,eventdata)TSAF('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.


@Jan, please watch my tutorials on TSAF to learn how I remove trend and seasonality.


Iman, which method is behind detrending and removing seasonality in data? Are some tests implemented here, like stationarity, normality or can I get advice where is the best to do these tests? I am predicting time series.


@Teena, please email the excel file to

Teena Sharma

hi Iman ,
as I am trying to import the excel file , TSAF is giving the message " the specified column contains no data " . I have downloaded the TSAF version that is mentioned here . KINDLY HELP

safia khalid

HI Iman
im anew beginner in matlab and i concernd with TSAF GUI to solve my research problem can you make a tutorial to learn me how ican download TSAF GUI please
with my great respect


Thanks Iman for sharing, great tool . Quick question, is there a way to deploy this tool ( using the Matlab deploy App for example of any other methods) to Excel for instance or as a stand alone application such as .exe ?


Hi Areeha. Thank you for your feedback. You can go through the code (m file) and copy all the parts you need in your script. cheers!

Areeha Durrani

Hello Iman. Thanks for great tutorials. Just wanted to ask if I can use it in my code (Script) like other tools of matlab?

Ioannis Papayiannis

Satyabrata Parida

Sincon Wulker

A great work! I really appreciate you. Thanks.


@xinquan which options are missing? could you please take a screenshot and email it to me? Thanks!

xinquan chen

Can not display the full window.MATLAB 2015a

when i click estimate button, it shows "system is not either stable or casual".what does it mean?
Thank you

Saif Mian

Great work!


Hi iqrar. Please watch my tutorials on this page.

iqrar afridi

hello sir
i want to forecast electrical what can i do? and which technique should i have used?

amin s


Perfect!!! thanx a lot!



Hi Zakar, Did you copy the files into the current directory of MATLAB? You can find this folder by typing "pwd" in the command line.

Zakari Seybou

Hi Imran, i am using MATLAB_R2015 and MATLAB_R2016b, on both versions the TSAF is giving me error: Undefined function or variable 'TSAF'.
Can you help me please.


Hi Na Ja,

Thanks for reporting this issue. Could you please take a screenshot from the TSAF window and email it to me ( I want to see your settings. Thank you.


na ja

The code works excellent till the estimate part, but, when forecast is pressed; min and max values are entered; the following error appears.

Error using TSAF>forecast_Callback (line 930)
Argument 'NumPaths' did not match any valid parameter of the parser.

Error in gui_mainfcn (line 96)

Error in TSAF (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)TSAF('forecast_Callback',hObject,eventdata,guidata(hObject))

Error while evaluating uicontrol Callback

What could be the problem?

DangDang Lang

excellent work

Pieter Jacqmaer


Thanks a lot Yacine.

Yacine boumaour

Very helpful and complete GUI as a student it helped me a lot, keep the good work,


Hi Mustapha. I am sorry to hear about the problem with TSAF. I changed something in the initialization part of the code which I think might be problematic. The new version is uploaded here. Could you please delete the old version of TSAF and download the new one? Please run it again, and let me know if you still get the same error message.

Thank you for your valuable time and helping me find the bugs in TSAF.


Thanks for the GUI. When I import my twelve points data from excel into TSAF I get the follwing error message "selected column contains no data!". When I input "arima(1,1,1)" at the Matlab prompt it ran quite well.


Hi Christian, thank you for using TSAF. You cannot directly use a variable in TSAF, but it is super easy to save the variable as an excel file. Here is an example:

a=[1 2 3 4 5 6].'; % the variable

The variable is now saved in an excel file named test. You can find this file in the current directory of MATLAB. If you don't know where the directory is, just execute "pwd" in the command line. Please let me know if you need more help.


Can I use a matlab variable instead of importing an excel file???


@Nima, Thank you for using TSAF.


TSAF is awesome :) Thanks a million Iman for your great tutorials and effort ! Good Luck



Awesome. Thanks for using TSAF.

Mahsa Ghaffari

Hi Iman, Thank you so much for the help. The problem is solved. I get in touch in case of a new problem!
Thanks again and good luck.


Hi Mahsa. No wirries. Did you follow the instructions that I provided at the top of this page (Description section)? I can help you on the phone/skype. Please send me an emai to and we can set up a time.

Mahsa Ghaffari

Hi Iman,
Thank you so much again. I am using matlab2015 and I have installed Econometrics Toolbox but when I write TSAF it says that it is undefined!
what should I do?
I really appreciate your answer.


Hi Mahsa. My pleasure to help. Actually missed data sometimes can be problematic.If you are missing a few observations, that wouldn't be a big deal but make sure that you remove empty cells from the excel file before using TSAF. If it is time-consuming to find and remove empty cells you can easily do it with a few lines of code. If you need more help please let me know.

Mahsa Ghaffari

Thank you so much Iman, very helpful!
Just one other question, what if there are some missed data? Can we just simply put an empty cell in the column?
I mean the periods between all data should be the same, like one year (because there is just 1 column which is for example the number of accidents for each year) but how should I bring into the analysis a data that is missed in one year?
Thank you so much for your answer.


Hi Mahsa, You can import excel files (csv, xls, xlsx) in TSAF. Data must be stored columnwise, i.e. each column is corresponding to the observations of one random variable.

If you download the package, you can see three examples in the "test folder". When there is just one column of data, TSAF automatically import that column (like the examples in the test folder). But if there are more than one columns, TSAF will ask you which column you want to work with.

Please let me know if my explanation is not clear. Thank you for using TSAF.

Mahsa Ghaffari


Would you please let me know how is the Data file you imported to TSAF? What did it include?



Thanks for using my GUI. Don't forget to rate BTW :)

Amir Feyzi

You're right. This solved the error. Thanks.
Good job, BTW.


Amir, Sorry for the trouble. I guess you don't have "Econometrics Toolbox" or your license for this toolbox has been expired.

Please run "arima(1,1,1)" in the command line and let me know if you get an error. If so, you have the aforementioned issue. In this case, you can download, the free trial version of "Econometrics Toolbox" and use the GUI.

Amir Feyzi

Mentioned problem exists on MATLAB 2015 not on the previous versions.

Amir Feyzi

Running test data produces an error, "Selected column containts no data!,"
and the functions do not work.
The error in command line:
Error while evaluating UIControl Callback

Reference to non-existent field 'data'.

Error in TSAF>pushbutton11_Callback (line 1354);

Error in gui_mainfcn (line 95)

Error in TSAF (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in

Error while evaluating UIControl Callback

farnoosh talaei

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!