File Exchange

image thumbnail


version (876 KB) by Nobuhito Mori
PIV method in MATLAB


Updated 13 Jul 2009

View Version History

View License

'mpiv ', PIV toolbox in MATLAB, is a program made for the beginner of PIV (Particle Image Velocimetry) method. The main reason why I made this program was educational purpose for undergraduate and graduate student. The code is simple and may easy understand.

Since fall 2002, several algorithms has been added and mpiv has sufficient accuracy and options at present.

Cite As

Nobuhito Mori (2021). mpiv (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (25)

Nobuhito Mori

Please cite following link and paper.

Mori, N. and K.A. Chang (2003) An experimental study of a horizontal jet in a wavy environment, Journal of Engineering Mechanics, American Society of Civil Engineers, Vol.129, Issue 10, pp.1149-1155. doi:10.1061/(ASCE)0733-9399(2003)129:10(1149)

Hao Yu Dai

Thank you senpai, could you tell me how to cite?

Fres Wong

Azalin L

it's very useful for me :)

Nobuhito Mori

You need enough number of particles or some characteristic patterns to estimate vectors in your input images. If there is no patterns, mpiv cannot estimate movement of patters.

Heather Cirka

I really like this code, but do have a question for other users.
Recently I began running an image against itself, expecting to get zero or the program to fail.
I end up detecting vectors (although small ones). Does any have any understanding of why this might be the case?
Thanks in advance

Nobuhito Mori

I think there are several required level of image.
1. enough particle density in the image
2. uniformly distributed particle in the image

If your image is not satisfy above two conditions, 'mpd' is more robust to obtain vectors.
here is sample script to obtain attached results.
[xi,yi,iu,iv] = mpiv(f1,f2, 64,64, 0.5,0.5, 20,20, 1, 'mqd', 2, 1);
[iu_f,iv_f,iu_i, iv_i] = mpiv_filter(iu,iv, 2, 2.0, 3, 1);


Help! I can run the examples bmp with no issues, but with my own ones i get this error.

??? Error using ==> chckxy at 106
There should be at least two data points.

As i have more 'speckle' images i used 'mqd' and the above error presumably came from an abundance of

Warning: Divide by zero.

during processing...and advice?




It would be simply great if anyone could help me understant the reason for this error: Reference to non-existent field 'pushbutton_filename1'.

Error in mpiv_gui>pushbutton_filename1_Callback (line 225)

Error in gui_mainfcn (line 96)

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

Error while evaluating uicontrol Callback.

Thanks & Regards,


could you plz mail me the documentation of this to my email(,it's a great help for me to understand the code.i need this for my project Looking forward for your help.

Azalin L

Thomas Clark

DACE kriging toolbox can be found here:

MacGuiness MacGee

If anyone else is having the same problem, you need to download the DACE kriging toolbox. Excellent program - many thanks.

MacGuiness MacGee

I have had the same problem as Glen Lichtwark - I receive the following error message: Undefined function or variable 'dacefit.' I'd appreciate it if someone could help with this.

Thomas Clark

Not advanced, but that's not the point - for someone learning PIV this is straightforward, flexible and extremely well documented.

Top marks, and thankyou for the time and effort which has clearly gone into this submission


Azalin L

it's very useful for me ;I

Harold Odom

Nico Krause

the subpixel find function is incorrect. the x and y direction are interchanged.

Glen Lichtwark

I had a problem getting th example data to work. The error was -->
??? Undefined function or variable 'dacefit'.

Error in ==> C:\MATLAB\work\mpiv_toolbox\vector_interp_kriging.m
On line 87 ==> [dmodel,perf] = dacefit( S, Y, @regpoly2, @corrgauss, theta );

Anthony H

Excellent but it will be more helpful if the accompanying user manual can cover abit more information, especially for each function called during the tracking process.

Thanks Mr. Mori.

James Young

A good implementation of PIV in Matlab with excellent accompanying documentation.

. .

C.S kim

it's very useful for me


This is good to understand PIV on MATLAB

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