File Exchange

image thumbnail


version (14.4 KB) by Antonio Trujillo-Ortiz
Hotelling T-Squared testing procedures for multivariate samples.


Updated 15 Apr 2005

View License

Hotelling's T-Squared multivariate test for one sample, two independent samples [homoskedasticity or heteroskedasticity (to test)] and two dependent samples.

Cite As

Antonio Trujillo-Ortiz (2021). HotellingT2 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (29)

xiaojun pan

Marcos Passos

Anybody knows which distribution Hotelling T² in the frequency domain has?

Ankit Suthar

Francesco Deleo

Thanks! It is very useful! I did some little changes in order to avoid the use of the interactive dialogs.

dhaba india



Not working for multivariate samples - not even with the data matrix supplied...

Andrea Libri


True about the NaNs when variance of variables is null (in T2Hot1.m). Well done though!



I get NaNs as output when variables with zero variance are present. After removing those as x(:,find(var(x,1) == 0))=[] , everything works :)

Arnaud Trollé

Good program. Yet, I was wondering how to enter the expected means vector ; there is no example for this case. Normally, one should enter 2 expected means vector (one vector per group); but only one vector is expected according to the prompt. This is a point I don't understand. Could you enlighten me ?

Best wishes,


I actually had an issue with HotellingT2.m and associated files. While computing T2 statistics for permutation testing, I noticed that the computed statistics were always the same, despite permutation of group labels. What I didn't realized is that the code assumes groups are in contigious blocks within the input data matrix. This however is easily fixable. Otherwise, these files provide a very useful function.

Anton Semechko

exactly what I was looking for, thank you


very good and easy to use. It has alot of examples which explain it very well


Actually, yes. It's odd that Mathwork implemented one-way MANOVA ('manova1.m') without more simpler statistic such as Hotelling's T^2.


I just checked one-sample (T2Hot1.m) using an example 13.3 from Armitage et al. Statistical Methods in Medical Research, ed. 4. The results are nearly the same, which is very good:
From book: T2=7.439, F=1.24 and P=0.39
From T2Hot1.m: T2=7.4315, F=1.2386 and P=0.3873

Very good job!

Ji Cling

Oh, little frog.
Make frequent 100th download leaps to keep that other one behind me!

Todd Pataky

Very helpful, thank you!

Michel Hamman

My Dear Ji Cling,

Regularly I visit this FEX site in which excellent contributions for the fast solution of diverse types of problems in several disciplines have been given. The accusation that you are causing is very delicate. I do not know you. Neither the authors. We known them only by the references given in their author page. Only what I believe is in the quality of ethics of each one of them and ours. We are serious people dedicated to our work in the most diverse specialties. To be certain what you say. Then not alone this author does cheating but also all the others. Even you, that in principle, I think you are not signing with your true name. Finally, or really the community are honestly dawnloaded the m-files or finally someone are doing a very bad play. This because there exists a lack of control on this.

Best Wishes.


Ji Cling

Self downloading 1000ths of times to get to the top of the rank.

rung siri

Krish Niar

Barbara Strzelczyk

Leila Reddy

Very helpful and well commented.

Stefan Bleeck

requires the statistics toolbox

Luis Concha

Extremely helpful. It's hard to find programs that will perform Hotelling's T2 test, specially in an easy way. Well commented, clear results.

Orlando Valladolid

Its very Good.

Ju wang

MATLAB Release Compatibility
Created with R11
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!