File Exchange

image thumbnail

X-13 Toolbox for Seasonal Filtering

version 1.50 (2.2 MB) by Yvan Lengwiler
Matlab toolbox providing access to X-13 seasonal adjustment programs of the US Census Bureau.


Updated 06 Jun 2021

View Version History

View License

The X-13 Toolbox for Matlab is a shell for interacting with the programs of the US Census Bureau, known as X-13ARIMA-SEATS, that perform seasonal filtering. The X-13 programs are the "industry standard" and are widely used by many statistical agencies and researchers. The toolbox ought therefore to be useful for statisticians or economists who use Matlab, and who lacked access to the standard seasonal adjustment method until now.
The toolbox contains a graphical user interface, called guix, that allows you to perform X-13 computations interactively. This can be useful for novice as well as expert users and is probably to best way to learn about the possibilities of X13.
The toolbox contains a documentation in a PDF as well as demo files that should help you understand how to use the toolbox. The X-13 program has a plethora of specifications one can fiddle around with. The best source to learn this is the original US Census Bureau documentation. Their website also has working papers devoted to this topic (see
The toolbox supports the X-13ARIMA-SEATS and the X-12-ARIMA programs of the US Census Bureau. The older X-11 program is not supported, though. An approximate version of X-11 is implemented in Matlab as part of this toolbox. In addition, the toolbox contains some other programs that are independent of the Census programs. These programs (x11, method1, fixedseas, seas, camplet) can be used with arbitrary frequencies, not just monthly or quarterly data like the Census programs.
Note: To get the complete functionality the toolbox requires freely available executables from the US Census Bureau in order to run. It attempts to download these executables automatically for you whenever you need one that is not on your harddrive. Of course, that works only if you are online, and it is limited to Windows computers. Versions of these programs for other operating systems are available from the Census website, however, and can easily be installed manually.
Please comment below if you find this software useful.

Cite As

Yvan Lengwiler (2021). X-13 Toolbox for Seasonal Filtering (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (99)

Gregor von Schweinitz

Yvan Lengwiler

Maybe you can give me some stars :-)

Lutz Kilian

Thanks. That's very helpful.

Yvan Lengwiler


disp(x.d11) gives you something like this:
descr: 'final seasonally adjusted data'
type: 1
dates: [597×1 double]
d11: [597×1 double]
So x.d11 is actually a struct with four components. x.d11.descr is a description of the content (here ' final seasonally adjusted data'), type is a code indicating what kind of variable this is (1 here means its a regular time series). x.d11.dates is the dates vector and x.d11.d11 is the series you are looking for.

So you can retrieve the adjusted series with x.d11.d11.

The reason why this is organized in this roundabout fashion is that some variables have more than one component. The data structure that holds the variables that result from the seasonal adjustment must be a little more flexible than simple vectors. This is why everything is packed up in a struct.

Hope that helps, Yvan

Lutz Kilian

Suppose I seasonally adjust the scalar time series y1 with dates y1dates using: x=x13([y1dates,y1]). How do I extract the seasonally adjusted series from the structure x, so I can view it as a regular Matlab vector? disp(x.d11) tells me that the series exists, but not how to view the numerical output. Plotting the data as in the demo does not address the issue.

Yvan Lengwiler


Thank you so much. You make me blush. :-)



Please, somebody give this guy (Yvan) a medal for all the effort and support he is providing on the top of providing the X-13 MATLAB implementation itself. Thank you sir.

Yvan Lengwiler


There is actually an easier way that I had implemented but that I had completely forgot :-o

If you define a variable ramadan that contains just the exogenous variable you want to add to the regression, you can say the following

spec = makespec([...], 'regression','user','ramadan', 'regression','start','2000-jan')

where [...] are all your other specifications. '2000-jan' is the date at which the ramadan variable starts (set this according to your application). If you leave the 'regression','start','date part away, the program will assume that the ramadan variable starty in the same month as the variable you are adjusting.

You can then simply perform the seasonal adjustment like this:

x = x13(dates, data, spec)

where dates and data are, as usual, a date vector and the time series you wish to adjust.

I had implemented this because I thought that creating an external file was ciûmbersome. But I have used this feature so rarely myself, that I actually forgot about it.

Sorry, Yvan

Seth Leonard

Hi Yvan,
Thanks so much, this is superb! Thanks particularly for the working example --- that makes it very easy to implement. Appreciate the help,

Yvan Lengwiler

Hi Seth,

Yes, this is possible. All the gory details are explained in the X-13 Documentation in section 7.13. But this still needs to be translated to using this with the toolbox. So here it is:

Prepare a file called ramadan.dat. This is a simple text file. Each line of this file corresponds to a month (assuming your regression uses monthly frequency). The first entry is the year, then a space, followed by the month (a number between 1 and 12), then a space, and then a value. This value is the exogenous variable that will enter your regression.

Now Ramadan does typically not start on the first of the month in the Gregorian calendar. So I don't know who you want to address this. You cound have a zero value for all the Gregorian months outside Ramadan, or you could have a value of the share of the month that is during Ramadan.

For instance, the entries for the year 2020 could be as follows:
2020 1 0
2020 2 0
2020 3 0
2020 4 1
2020 5 1
2020 6 0
2020 7 0
2020 8 0
2020 9 0
2020 10 0
2020 11 0
2020 12 0

Since Ramadan was from 23 April 2020 to 23 May 2020, I have places a 1-dummy in April an May. You could also do this instead:
2020 4 0.2333
2020 5 0.7419
reflecting the share of the Gregorian month that is in the Ramadan month.

Do this for all years so that your sample (and possible forecast sample) is covered.

Then, say this in Matlab (or in your script):

addramadan = makespec( ...
'regression','user','Ramadan', ...
'regression','file','ramadan.dat', ...
'regression','format','datevalue', ...
'regression','usertype','holiday', ...
'regression','save','hol', ...

Finally, make the specifications using makespec for your seasonal adjustment

spec = makespec([put all the specs you need here], addramadan)

and run the adjustment procedure

x = x13([...],spec,[...])

as explained in the documentation.

Hope this helps, Yvan

Seth Leonard

Hello Yvan, thanks for putting this together! One question: is it possible to specify user defined (holiday) regressors? In particular, I'm interested including Ramadan in a seasonal model. Many thanks!


Dear Yvan
Thank you for your support here. It is greatly appreciated. Is there an intuitive intro chapter to X-13AS? I understand time series in general but all I find is documentation (which assumes I know what X-11 does, at least), or it takes 120+ pages, or both. I searched the internet, but nothing that is accessible AND concise.

Also, in an order to learn more I tried to "brute-force" it, but I could not even specify a CPI series that is published on the 1st and 16th of every month. Could you show me a pseudo-sample code? What do I need to specify/how do I use makespec and x13spec?

Yvan Lengwiler

Hey Marco,
I don't know ts2arr either. This is not a command from this toolbox. What is it supposed to do?


Dear Yvan, This is great work. Many thanks for putting this toolbox together.

One question. I'm trying to run the code and I receive an error message when calling the function ts2arr. I cannot find this function anywhere. I'm using R2019. Any clue?

Sinan Islam

Yvan Lengwiler

Thank you. You are welcome :-)


Thank you Mr. Yvan. It is really great to have this SA toolbox for MATLAB. The examples in the toolbox documentation were very helpful, too.

Yvan Lengwiler

Dear cka,

That is easy. Let x = x13(dates,data, ...) be your X-13 variable. You can check if the procedure says that it should not have been treated in the first place by asking

contains(x.err,'Series should not be a candidate for seasonal adjustment')

This returns TRUE if this particular error is present and FALSE otherwise.


Dear Mr. Yvan,
When a series x has NO seasonal component, then running 'SAobj = x13(x,dates, spec)' does the following:
1. prints a warning in MATLABs command window:
'Series should not be a candidate for seasonal adjustment because the spectrum of the prior adjusted series (Table B1)', which is stored in xo.msg,
2. prints 'IDENTIFIABLE SEASONALITY NOT PRESENT' at the end of Table D8A, which can be accessed via disp(SAobj.table('d8a')).
Even though it detects NO seasonality, it nevertheless decomposes the timeseries (i.e. there is a supposedly SA’ed series in SAobj.d11.d11). Is there a way to instruct the x13(…) function, not to estimate the decomposition when no seasonal component is detected?
Or otherwise, is there a way to extract the result (i.e. the test statistic, not the qualitative textual response) of the combined test for the presence of identifiable seasonality, and store it to a variable?
Many thanks!

Yvan Lengwiler

It can happen that the X-13 algorithm is unable to find a model that captures all recurring patterns in your data. The message means that there is a pattern related to the varying number of trading days in your months or quarters. You can try to test (and possibly correct) for those by adding a trading day dummy to the regression. X-13 has that built in, and you can use it by adding 'TDAYS' to your specification, so say spec = makespec('TDAYS', ... [the rest of your specification]). If you use guix, simply check the 'trading days' checkbox in the REGRESSION and OUTLIERS section.
Hope that helps, Yvan

Tayushma Sewak

Hi Yvan

I am using your toolbox to deseasonalise my data in Matlab. It works for all variables, except for the local IP in some countries. The message displayed is as follows: At least one visually significant seasonal peak has been found in one or more of the estimated spectra. I understand there are some outliers, when I plot my data. However, none of the specifications for TC, LS or even NO OUTLIERS seem to work.

I shall be really grateful if you could share some insights.


Tayushma Sewak

Also sincerely sorry for misspelling your name.

Yvan Lengwiler

Stefano. The toolbox is designed for Windows only. The Census programs are available for different operating systems, and even the source is available for you to recompile. But the toolbox would likely require changes to work with a Mac.

Stefano Pica

Has anyone run this on a Mac? If yes, which steps did you take? Thank you

Alisher Tolepbergen

Dear Yvan,

I cannot access the census webpage.

Could you please send me the missing programs?

Thanks in advance!

Eduardo Kasa

Yvan Becard

Yvan Lengwiler

Glad to be of service. And thanks for the verbal support. Maybe you can back this up with a few stars in the feedback :-) ?

I found that there is indeed an incompatibility with the new version of Matlab. It concerns only the seas program (used for data that are neither quarterly nor monthly), not the x13. An update of the toolbox should be posted in the next few weeks once I am done with updating it.

Yvan Becard

Hi Yvan, thanks this is correct, I am using another piece of software (Dynare) and it has an x13 toolbox, which was conflicting with yours. After removing that one from the path everything works fine again. Thanks for your help, sorry for the inconvenience, and keep up the good work! Cheers

Yvan Lengwiler

Ok, that means that x13 is an external file/function. It's not a built-in function.

Trouble is, I use Matlab 2019 so I cannot reproduce this error.

Moreover, the error happens on line 86 of x13 according to the error message. However, line 86 is well inside the header (containing only commentes) in my file. This means that you must have some other file named x13 in your path that is unrelated to the one of the toolbox.

This implies that you must have another file x13.m in your path that is unrelated to the X13-toolbox. Could you search your harddrive or path for all files called 'x13.*' ?

And finally, one more issue: I don't know what a dseries is. This is not a standard variable class in Matlab 2019. Can you determine what dseries is on your system? Could it be a class that is defined in another toolbox?

Yvan Becard

Hi Yvan, thanks for the reply, it returns 2.

Yvan Lengwiler

Yvan, I have to look into this. What does

exist x13

return on your installation?

Yvan Becard

Hi, I was using the toolbox just fine, since I upgraded to Matlab 2020a I get this error message

Error using x13 (line 86)
x13:: Wrong input argument (a dseries object is expected)!

Is x13 a built-in function in Matlab now?

Yvan Lengwiler

Ikmal, Here's the short answer: no, very unlikely.

And here's the longer answer: First of all, you would need to have executables of the Census Bureau programs that run on a Mac. These are, to my knowledge, nit readily available, but it may be possible to compile them from source. Next, the interface of the Toolbox with the input- and output-files of that software would very likely need to be adjusted. I do not have access to a Mac, so I cannot even begin to try.

I'm sorry.

Ikmal Rosli

Yvan, is there any way to make this toolbox available for mac users?

Yvan Lengwiler

Peng. I just sent you the file by email. V1.1_B26 is not the latest version. The latest available version is V1.1_B39. I sent you both.
Yours, Yvan

Yeshuo Peng

I can't download ' ' from . Is anybody who can help me? Download it and send to my email. My email address is . Thanks!

Tsotne Marghia

Yvan Lengwiler

That just means that you have requested the identification of additive outliers (AO), but none was detected. This is only for information; it has no further negative effect on your computation.

If you are not aware that you have requested detection of AOs it may be because detecting AOs is part of the default specification.

Shaoni Nandi

I get the following warning: Can you please guide?
MISSING VARIABLES: 'ao' was requested but is not available.
> In x13series/CollectFiles (line 3013)
In x13 (line 846)

Yvan Lengwiler

I just sent you the files by email.
Yours, Yvan

Tsotne Marghia

Hello everyone

Unfortunately I cannot access census website either using matlab nor even directly from browser. Can someone send me the executables that are on the census website?

Thank you in advance

Yvan Lengwiler

Dear Jung,
You can use the new 'makedates' utility (new in Version 1.34) to help you make the date vector you need.

Yvan Lengwiler

Dear Jung,

Your datevector must be a datenum or a datetime class vector. See doc datenum or doc datetime to see how you can create such a vector. And ask again if you have trouble.

Cheers, Yvan

HabGyuk Jung

what form do I have do use for dates vector
2019M01 2019M02 form does not work

Yvan Lengwiler


Maybe one comment: CAMPLET is designed so that there are no revisions when the time series is extended with new data. This feature can be useful. It achieves this by using only backward looking filters, so there are no centralized or symmetric moving averages or kernels. As a result, the CAMPLET decomposition will feature an undesirable phase shift. This is, I believe unavoidable. But the flipside is that there are no revisions when new data come in.

Cheers, Yvan

Yvan Lengwiler


I was struggling with that for a while, and I think I am not able to explain it with more authorrity than the inventors. I suggest you study the original article:

Barend Abeln and Jan P.A.M. Jacobs, "Seasonal adjustment with and without revisions: A comparison of X-13ARIMA-SEATS and CAMPLET," CAMA Working Paper 25/2015, Australian National University, July 2015.

Cheers, Yvan

Christopher Bennien

Yvan, I don't really get how the Camplet program adjusts the series without any pretreatment. Can you explain the algorithm in a few words?

Thank you for your time!


yvan becard

Thanks for your invaluable help Yvan, problem solved.

Yvan Lengwiler

This problem is odd, and I cannot imagine that it has something to do with you changing Matlab versions. The code that determines the frequency of the data does not use version specific code.
You could, in principle, set the frequency manually by adding 'series','period',12 into the spec (for monthly data), or 'series','period',4 for quarterly data, respectively.
In oder to help you more I would need to see the data you use, in particular the dates vector you use. Could you send me this by email? I would be glad to analyze it.
Yours, Yvan

yvan becard

Hi, thanks for the nice toolbox. It was working perfectly well, until I changed my computer, I now have Matlab R2018a, and I get this error message:

Error using x13series/PrepareFiles (line 2183)
Automatic frequency detection failed. Please specify
the correct frequency of the data manually with

Do you how I solve this?

Yvan Lengwiler

Dear Yunzhi,

I've added more complete error messages for the case when the download fails. The extended error messages instruct the user which URLs to use to download the files manually, and then what to do with them.

It will be part of the next update of the toolbox (probably when the next version of x13as is published by the Census Bureau).


Benlaron LU

Hi Yvan,

Thanks for your outstanding toolbox. However, some guys like me may fail to download x13as from Census Bureau directly by entering InstallMissingCensusProgram.m in command window. So, an instruction for manual installment would help a lot.

However, given that the organization of your code is pretty good, I follow your website list in InstallMissingCensusProgram.m and download files listed there via VPN manually. I also double check your Readme.txt in the "\exe" folder.

Anyway, I do appreciate your contribution.


Yvan Lengwiler

Duc Huy,
Maybe. How much of a beginner are you? Do you know some Matlab but are a beginner in seasonal adjustment? Or are you also a beginner in Matlab?
Yours, Yvan

Tran Huy

Can you help me step by step because I am a beginner?
Thank you in advance!
Tran, Duc Huy



Thanks a lot! :)

Yvan Lengwiler


I believe your syntax is wrong. The first argument should be a column vector containing dates, the second argument should be an equally long column vector containing the data. Alternatively, you can also use a T x 2 array with the left column containing the dates and the right column containing the data. The next argument must be a x13spec object, which contains the specification passed on to the X-13 procedure. If you do not provide a specification, a default can be used. The default specification can also be had by saying makespec(). Any arguments after that are optional. You set 'x-13'. I suppose you want to force x-13 instead of x-12. But x-13 is the default anyway, so this argument is not required.

So, assuming that gdp' is a T x 2 array, consider this

x = x13(gdp')

or alternatively

x = x13(gdp',makespec())

or yet more specific

x = x13(gdp',makespec(),'x-13')

All three variants should produce the same outcome.


I tried to run the toolbox by using the following code:

x = x13(gdp','x-13');

And got this error:

Undefined function or variable 'compositeSpec'.

Error in x13 (line 745)
x.specgiven = [spec,{compositeSpec}];

Could anyone helps me with that?
Thank you in advance!

Yvan Lengwiler

Fabian, It's not completely clear. Maybe you have missing values at the send of your data? I cannot say without seeing your date and HICP-ExEnergy data. You seem to have quarterly data, is that correct? What is surprising is that the last year of your data appears to be the year 117. Is this intended?

It might also have something to do with the fact that date has a meaning in Matlab. Maybe you could try using a different variable name for the vector containing the dates.

Fabian Schupp

Hi, I tried to run the program with:

Test = x13([date,HICP_ExEnergy])

But I get the Error:

ERROR: Model span not within the span of available data.
ERROR: model span end date, 117.2, must end on or before
span end date, 117.1.

Not sure, how to read this. Is it in obvious mistake anyone can help me with?

Tri Dung Nguyen

Yvan Lengwiler

Sure, I can try to help you. But I do not have access to a Mac, so my possibilities are limited.
The first step, I guess, is to download the source from here:

Stephen Morris

Hi Yvan - I experienced same problem as Christian trying to get this to run on a Mac. I noticed you had said you might be able to run using source code, but he opted out. Would you be willing to help me take this route?


Yvan Lengwiler


Do you use quarterly data? In that case, remove the 'SPECTRUM' from the specification, because spectra are only computed with monthly data. This will get rid of some of the errors, but not all of them.

Missing variable s11, s12, s13, s16 actually means that the seasonal adjustment is, for some reason, not performed. This can have several reasons, I could try to walk you through it. But honestly, I think it's easier if you could just send me the offending series ( and I'll take a look at it.



thanks for your replies. I made some progress: I found out that some series produce s.a. output if I remove leading NaNs. Still, even without any NaNs, no s.a. output is produced in some cases. That is quite mysterious. I've got the following error message: "MISSING VARIABLES: ''s1s'', ''s2s'', ''ser'', ''sp0'', ''spr'', ''st0'', ''str'', ''t1s'', ''t2s'', ''ter'', ''s10'', ''s11'', ''s12'', ''s13'', ''s16'', ''ao'', and ''td'' were requested but are not available.'"...

Yvan Lengwiler


By the way: the seasonally adjusted series is in d11 only if you use X-11. If you use SEATS, the corresponding variable is called s11.

Actually, maybe you want to check out the GUI I made for this toolbox. Just run guix from the Matlab prombt, enter the names of your variables containing the dates and the data, and then you can clic trough all options and run the adjustment in the GUI. That should help you find a working specification.

Cheers, Yvan

Yvan Lengwiler


The Census bureau program has the TRAMO-SEATS algorithm built in, so you should be able to use that as well.

I don't know what the default parameters of the Banco d'Espagna are, but you could try the following:

spec = makespec('TD', 'EASTER', 'AO', 'LS', 'AUTO', 'TRAMO', 'SEATS', 'ACF', 'SPECTRUM');
x = x13(dates,data,spec);

This will use TRAMO to identify the times series model and SEATS to do the seasonal adjustment. It will also automatically identify additive outliers (AO) and level shifts (LS), use dummies for trading days (TD) and the location of Easter in the year, and will choose an additive or multiplicative model automatically (AUTO).

Please let me know if that works for you.



Sorry for having been absent for a while. In the meantime, I have found a windows machine. So that might be the easier solution.

I have to admit that the program is somewhat of a black box to me. I previously used TRAMO-SEATS from the Bank of Spain. I just used their default setting and the program was reasonably fast.
When I re-run the code with your program (I basically used your demo code for the GDP example, but used some CPI data), I face 2 problems:
1. The code is somewhat slow.
2. For some countries, I do not find any d11 series, even though the input series of data cover >10 years of quarterly data.

I'm less concerned about the first problem, but I'd like to fix the second problem. In particular, I wonder whether there is a robust default option that gives me a reasonable seasonal adjustment, maybe similar to the TRAMO-SEATS program offered by the Bank of Spain.


Yvan Lengwiler


Actually, I just saw that the source of the x13as program is available from the Census website. So, if you feel confident to recompile it on the Mac, we could make it run :-)


Yvan Lengwiler


Actually, it seems that Linux programs do not run on a Mac unless you have access to the source code (which isn't public in this case) and can recompile. Alternatively, you can use a Linux virtual machine on your Mac, but that would require to run Matlab also in this VM, so ...

See for instance here,

If all of that is true, it probably means that you cannot use the Census programs on a Mac. You can still use the fixedseas and camplet methods of the toolbox, because they do not rely on the Census programs, but of course, the quality of seasonal filtering is not comparable to what the genuine X-13ARIMA-SEATS provides.

Yvan Lengwiler


Your're the first user I know of who uses this toolbox on anything but a Windows computer.

The Census Bureau offers their X13 programs in a DOS, ind a Windows, and in a Linux version. This Matlab toolbox uses the DOS versions by default. I don't know if the Linux version runs on the Mac (given that the MacOS is, I believe, closely related to Unix). If the Linus version does run, we might be able to fix the toolbox so that it will work on a Mac :-)

In any case, the x12diag03.exe is an addition to the main x13as.exe that is not really important. This program is also available from the Census website, but if that doesn't work that is almost inconsequential. Just comment out that portion in the X13DemoGDP file.

The only crucial part is to know if the Linux version of the Census program works on the Mac. I cannot test that because I do not have access to a Mac. Maybe you can test that? You can download the Linux versions from here: If you've downloaded the DOS versions, just delete them. They will be of no use on your computer. After placing the Linux version of x13as (and possibly of x12diag03 as well), you could try again and tell me if it works. I expect some iterations of this before it might finally work...

Let me know how it goes,


Thanks for your reply, Yvan. I've got the directory structure the way you say it should be. I think one problem was / is that macs like to use slashes instead of backslashes. Your program doesn't find x13tbx\exe\ because it's x13tbx/exe/ on a mac. That's why it creates a folder with the name 'x13tbx\exe\', I think. Anyway, I adjusted that in your code and now it no longer creates that folder.

But I still get the same error message that it can't fin the field x2d. I try to find the place the place where that field is supposed to be created, and it seems to be in x13composite.m, line 710. The resulting 'console' variable that I get says:
'/bin/bash: /Users/hansschlemmer/Desktop/x13tbx/exe/x12diag03.exe: cannot execute binary file'

That doesn't sound good...

Yvan Lengwiler

I'm sorry to hear about your trouble, Christian. The directory structure must be as follows: x13tbx, x13tbx\exe, x13tbx\@x13series, x13tbx\@x13composite, x13tbx\@x13spec, x13tbx\doc, x13tbx\demo, x13tbx\tools (this last one is optional).

The program uses the exe-files in the folder x13tbx\exe (so, for instance, x13tbx\exi\x13as.exe and x13tbx\exe\x12diag03.exe).

Could you please try to adapt your directory structure in this fashion and tell me if that helps?


Thank you, Yvan!

I can't get the demos to run. For instance, for the GDP demo file, I get the following error:

No appropriate method, property, or field 'x2d' for class 'x13series'.
Error in X13DemoGDP (line 97)
strOUT = xgdp.(allseries{c}).x2d;

I manually downloaded the .exe files, and put them into the .exe folder. Strangely, your code also seems to create an additional .exe folder, called x13tbx\exe\, in the same location as the x13tbx folder.

In which variable do I find the s.a. series?


Roger Zhu

Yvan Lengwiler

Thank you, Bugme, for these words. I am glad that my work has proven useful for you ... and thanks for pointing out this mistake. It will be corrected in the next release. :-)

Bugme Nottrash

Dear Yvan,

a million times thank you for this great work! You spared me hundreds of hours of work to interface the X-13 Applications. And your Demos: Outstanding, thank you for that!

Hint: In your Demo-File X13DemoFIXED.m (Line 153), there is an typo; it should be:

c_20 = corrcoef(resid(ok_20),;


Wayne Zhang

Dear Yvan,
Thanks for your help and I have made it work. It is really a good Toolbox.

Yvan Lengwiler


It should be easy to download. If the Matlab program cannot doenload it automatically, you should be able to find the programs on the Census website. However, I just sent you the files my email. That is probably even easier.

Let me know how it goes.

Cheers, Yvan

Wayne Zhang

Dear Yvan,

Tht CensusProgram can not be downloaded, could you send me by email. My email address is


YoungMin Kim

Yvan Lengwiler

The new version 1.20.2 addresses the bug discovered by Carlos.


Thank you!! I made it work!

Yvan Lengwiler

Thank you, Carlos. You have uncovered a bug. Could you please change the following lines in x13.m:

line 636: 'toolbox (''%s'').'], '', progloc);

line 655: 'toolbox (''%s'').'], theZIP, progloc);

So in both cases, the p must be replaced by progloc. I will upload a bugfix in the next few days.

But this will not solve your problem (it will only make the error come out correctly).

It appears that your computer is unable to download or install the software from the US Census Bureau. You will need to do this manually.

Browse to and click on the link on the left 'Download X-13 (PC)' if you use a windows computer, or 'Download X-13 (Linux)' if you're working on a Linus computer.

On the next page, locate the link to '' (or '' if you plan on using the 'accessible version'), unzip this archive and copy the x13as.exe file conteined in this archive to the exe subdirectory of your Matlab X-13 Toolbox.

After this, you should be able to run with the 'noflags' option,

x = x13([dateX,data_.HICP],'noflags')

'noflags' is necessary because otherwise an additional program from the US Census Website is required (x12diag.exe), and it is very likely that your computer will be unable to install that as well.

Please let me know if all of this helps to resolve the issue or not.


Hi! First, thank you very much for coding this! I am trying to run it, but I always get the following error:

x = x13([dateX,data_.HICP])
Downloading '' from US Census Bureau website ...
Undefined function or variable 'p'.

Error in x13 (line 650)
err = MException('X13TBX:X13:ProgramMissing', ...

dateX is a column vector with numerical Matlab dates, and data_.HICP is the vector of data. Could you please help me? Thanks!



Dear Yvan,

I sincerely thank you very much for your kind help to install your toolbox. I appreciate your efforts and Patience helping a matlab beginner.

An amazing toolbox!!


Yvan Lengwiler

Grace, Could you please send me your email to

Yvan Lengwiler


I'm sorry to hear about these troubles. The url works fine on my computer. Have you tried to browse to this link ( sing your browser? If that doesn't work, the problem must be in your interne connection or maybe the website is blocked for some reason.

In any case, I have recently made some changes to InstallMissingCensusProgram, but not yet released the new version. I send you the beta version of this program by email. Please let me know, first, if the link works, and second, if the problem goes away with the appended beta version.



Hi, I followed the steps to install the toolbox but still failed to get it installed. I am getting the following error message:

Downloading '' from US Census Bureau website ...
Warning: Download from url '' failed.
> In InstallMissingCensusProgram>InstallMissingPiece (line 254)
In InstallMissingCensusProgram (line 226)

Yvan Lengwiler

Dear Halil,
I'm glad it works. Let me know if you encounter other problems :-)

Dear Yvan, I can resolve the problem. When I install toolbox and then I reopen Matlab. Thank you very much for your helpful comments.

Thank you very much Yvan, I can do it with your directions :D

But I have also some questions when I run your toolbox, I have receieved this messages:

" We start our demonstration of fixedseas with some artificial data. These data
consist of a linear trend, two sinus cycles with periodicity of 14 and 20,
and some noise. We will try to identify these periods (as if we didn't know
them already) and then filter them out.

Error using plot (line 249)
First or second arg must be an x13series object.

Error in plot (line 799)
plot(ax(cntAx),dates,toplot, ...

Error in X13DemoFIXED (line 92)

Error in run (line 96)
evalin('caller', [script ';']);"

Yvan Lengwiler

Dear halil,
I'm glad you like the toolbox and I will try to help you resolve the problems you have encontered. To install the toolbox, you need to do the following:

1) Download the ZIP-File from the FEX.

2) Extract the ZIP. This will create a directory called x13tbx which contains files and several subdirectories.

3) Put the new x13tbx as well as x13tbx\demo into Matlab's path.

You should now be able to run the demos.

The Toolbox needs some files from the US Census Bureau website and attempts to download them on demand. To install all necessary files from the Census website, run InstallMissingCensusProgram once from the Matlab prompt.

Please let me know if this helps.

This is very useful toolbox thanks to Yvan Lengwiler. But, could I ask some questions?
1) Must I install all m.files in a one file?
2) I cannot run demo files :(
3) How can I install this toolbox in matlab?

Thanks and kind regards


Yvan, thanks for your program and the adaption to Matlab 2012b.



Great program and great timing for me - I only looked for an X13 tool for MATLAB yesterday.

Yvan has developed a very comprehensive and user-friendly tool, and with the updates all demos run smoothly on my system running R2014b.

Thanks Yvan!


MATLAB Release Compatibility
Created with R2020a
Compatible with R2012a and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!