PIVMat Frequently Asked Questions |
to load a single file (here 'B00001.VC7'). To load all the files in the current directory, type e.g.v = loadvec('B00001.VC7');
To load only files 1 to 10, usev = loadvec('*.VC7');
To display the fields, typev = loadvec(1:10);
There are several shortcuts: For instance, this will display a movie of all the files in the current directory:showf(v);
See the page Importing data into PIVMat to learn more.showf('*.VC7');
(open the help browser with the help for this function), ordoc loadvec
(display the text of the help in the command window). If you don't know what you look for, have a look to the Function by category section from the PIVMat main page:help loadvec
docpivmat
showf(filterf(v,2));
Then display it with the background option 'rot'v = loadvec('B00001.VC7');
Another way to do this is to create a scalar field curl,showf(v,'rot');
and then to display it:curl = vec2scal(v,'rot');
Before computing the vorticity field, you will probably want to filter your vector field:showf(curl);
Many other vector-to-scalar conversions (divergence, kinetic energy, velocity derivatives...) are available from vec2scal.showf(filterf(v,1),'rot');
Just refer to the fields you want with v(n), where n is a number (eg, showf(v(4)) displays the field #4).v = loadvec('*.VC7');
If you want to skip one field every 2, typeshowf(v(1:10));
You may also only load the fields you want, by using wildcards (*) and/or brackets []. In order to load only the files B00001.VC7 to B00010.VC7, typeshowf(v(1:2:10));
See rdir for details about the usage of the brackets []. There is also a shortcut to do so,v = loadvec('B[1:10].VC7');
(in this case, the 10 first files are loaded in the alphabetically-ordered set of files of the current directory).v = loadvec(1:10);
You may also display specify different spacing in the x- and y-direction:showf(v,'norm','spacing',2);
showf(filterf(v,1.5),'ken','spacing',[4 12]);
showf(v,'contourf',8,'spacing',[4 12]);
Display a movie of your fields,v = loadvec('*.VC7');
You can enter into the 'pause' mode by pressing the space bar. Then navigate using the left or right arrow. Press the space bar to run the movie again. Press ESC to escape. Use option 'loop' to run the movie in a loop. You may also directly enter into the 'pause' mode by specifying the option 'pause'. See showf.showf(v);
is stored into a "PIVMat structure" v. A PIVMat structure is a variable that contains several variables of different types (see 'Data Types > Structures' in the Matlab help). The structure v contains the axis, the velocity components, the field names etc. If the fields originate from DaVis, the PIVMat structure also contains several attributes saved by DaVis (acquisition time, etc). For instance, the x-component of the velocity field is stored in the matrix vx of the structure v. In order to refer (eg, plot, display, modify...) to the x-component of the velocity at the point (i,j), you should typev = loadvec('B00001.VC7');
If you have loaded several fields in a single structure v, e.g. withv.vx(i,j)
then v is now a "structure array". You can refer to the (i,j) point of the x-component of the n-th vector field withv = loadvec('*.VC7');
See Data Organization in PIVMat for a full description of PIVMat structures.v(n).vx(i,j)
(type doc colon to learn more about Matlab's colon (:)).plot(v.x, v.vx(:,12))
plot(v.x, mean(v.vx(:,10:14),2))
Then follow the same procedure as above. The vorticity is contained into the variable w of the structure vort:vort = vec2scal(v, 'rot');
plot(vort.x, vort.w(:,12))
Create a VideoWriter object:v = loadvec('*.VC7');
Call showf and close the movievid = VideoWriter('mymovie.mp4');
showf(v, 'savevideo', vid, 'rot', 'clim', [-3 3]); close(vid);
vid = VideoWriter('mymovie.avi'); imvectomovie('*.IM7', vid, 'clim', 2000); close(vid);
Then call the function statfke = vec2scal(v, 'ken');
What you want is the mean of ke:st = statf(ke);
st.mean
Then you can save your final set of scalar fields curl in a Matlab file,v=loadvec('*.vc7'); v=shiftf(extractf(v,[10 10 100 100],'phys'),'center'); fv=bwfilterf(v, 2, 8); curl=vec2scal(fv, 'rot');
You can retrieve your fields usingsave('mycurl.mat','curl');
Note that you can also load your fields using the standard Matlab's load function,rot = loadvec('mycurl.mat');
In this case, the field name (here 'curl') will be the same as the one specified to the save command.load mycurl
returns the time t of v (or the array of times, if v is an array of fields). You may also use the function getpivtime, which is a shortcut for this attribute.t = getattribute(v,'AcqTimeSeries0');
Then use averf with the following output arguments and plot the result:v = loadvec('*.vc7');
[af rms] = averf(v); showf(rms);
Then store the x and y components of the velocity at a given point, say (X,Y) = (20, 40) mm, using probef:v = loadvec('*.vc7');
then plot the result[ux,uy] = probef(v, 20, 40);
If you use DaVis files, you can use getpivtime and getattribute to get the time stored in each file.plot(1:length(ux), ux)
for j=1:length(v) d(:,j) = v(j).vx(:,12); end; imagesc(v(1).x, t, d'); xlabel('x'); ylabel('t');
If you typev=loadvec('B00001.vc7'); v=shiftf(extractf(v,[10 10 100 100],'phys'),'center'); fv=bwfilterf(v, 2, 8); curl=vec2scal(fv, 'rot');
you obtain the following cell array of strings:curl.history
In this list, ans refers to the result of the previous operation. See Programming > Data Types > Cell arrays in the Matlab help to learn more about cell arrays.'loadvec('B00001.vc7')' 'extractf(ans, [10 10 100 100], 'phys')' 'shiftf(ans, 'center')' 'bwfilterf(ans, 2, 8, 'low')' 'vec2scal(ans, 'rot', 'nonzero')'
When a string is passed as the first argument of filterf, the file is first loaded by loadvec. When no output argument is specified, then showf is automatically called. Numeric arguments may also be used:filterf('*.vc7',2);
displays the average of the 10 first files on the current directory.averf(1:10);
In this example, the string '%s' is replaced by the setname (i.e. the directory name where were stored the files), and the string '%t' is replaced by the current time of each field, as obtained by getpivtime.showf(v,'loop','title','%s, t = %t s');
This calls sequentially the function showf for each file matching '*.vc7' in the current directory, passing the additional parameter 'norm'.batchf('*.vc7','showf','norm');
(note the use of curly braces {} for cell arrays of strings - see rdir for details).file = rdir('*.vc7'); for i=1:length(file) v = loadvec(file{i}); st = statf(vec2scal(v,'ken')); k(i) = st.mean; end; plot(k);
However, you loose the ordering of the files doing so. If now you prefer to store your fields into a 2D array of fields, use loadarrayvecv = loadvec('myset*/*.vc7');
Use something like showf(v(1,:)) to display all the fields from the first directory, or showf(v(:,1)) for all the first fields from each directory.v = loadarrayvec('myset*','*.vc7');
Then you can average all the first fields from each directory, all the second fields from each directory, etc:v = loadarrayvec('myset*','*.vc7');
for i=1:size(v,1), af(i) = averf(v(i,:)); end; showf(af);
Then simply call your function with:function res = strangefield(v) res = vec2scal(v,'norm'); res.w = 2*v.vx + v.vy.^2; res.namew = 'strange field';
showf(strangefield(loadvec('B00001.VC7')));
  |