NOTE : This is not a matlab tutorial, this is my private Matlab notebook .. so do not expect too many comments. :)
Import LVM file
you can import LVM file by using lvm_import('file') from here
it returns a struc
Structures
usage similar to objects in C …. for example …
b=a.Segment1.data;
Rows and Columns
Lets assume we have a matrix Nx3
then to get second column we need to type : b(:,2)
Filters
nice filter example based on wav file
Example on Band Path Filter
n = 6;
% Frequencies to keep is between 200 to 800, while the sampling frequency is 4kHz, which leads to half frequency of 2kHz.
f = 4000
Wn = [200 800]/(f/2)
ftype='bandpass'
[b,a]=butter(n,Wn,ftype)
filteredData=filfilt(b,a,theData)
It is also possible to see the frequency response of the filter …
lets assume at f=4,000Hz …
f=4000
freqz(b,a,128,f);
Export Images of High Resolution
This example exports Figure No. 1 at a resolution of 300 dpi to a 24-bit JPEG file, myfigure.jpg.
print -djpeg -f1 -r300 myfigure
Statistics
Histogram
can be useful to check the distribution …
hist(data, number)
data is the data array …. number is the number of the bars to divide the histogram for … 7 is ok …
Plotting
BoxPlot
I spent so long trying to figure out how to change labels and their size in BoxPlot Matlab. Here I am jotting down my discoveries, and hopefully google would spread the knowledge for others to follow.
boxplot(something);
set(gca,'XTick',[1 2 3 4 5 ], 'XTickLabel',{'L-2' 'L0' 'L2' 'L2' 'L2'}, 'FontSize', 20 );
Interestengly, if you take the XTick off, it would not work !
There are more explanations on how to make it through childrens,pointers, and other non-direct approaches here
Plotting ErrorBars
Ploterr is a nice tool to plot horisontal or vertical erorr bars : [http://www.mathworks.com/matlabcentral/fileexchange/22216]
Fitting a line
very nice explanation is here : [http://www.ece.utah.edu/~harrison/ece6721/MATLAB_curve_fitting.pdf]
Simple Linear Polyfit
p=polyfit(x, y,1);
xx=(10:1:40)';
f=polyval(p,xx);
plot(xx,f,'-',x, y,'o');
Complicated one
fminsearch - give it a function and it would find the correlation …
Estimates=fminsearch(@myfit,Starting,options,x_err,y_err)
check correlation coefficiency
give it measured values and estimated, it would calculate the R ..
correlation=corrcoef( y_err , weight_estimate )
Pretty graphs …
http://blogs.mathworks.com/loren/2007/12/11/making-pretty-graphs/