Forums

EMG analysis in matlab

Started by mary27 July 8, 2011
Hi, I am having a project where I have to open a EMG signal from muscles in
matlab and use to it find a few parameters. I'm a beginner in matlab so I
apologize if my questions might sound too simple. 
first, the file for my signal is a .mat file. I know how to load it in
matlab but how can I open it as a figure? (a plot of my signal) I mean I
wanna see my signal in matlab.
second, I need to find the median frequency for this signal which is in the
time domain itself so it has to turn into freq domain first. I need the
median frequecy for 2 parts of signal, from the beginning to a certain
point in time axis, and then from there to end. How do I do that? 
I know about the functions in matlab that take median freq, turn to freq
domain etc but I need the exact code as an example. any help ASAP would be
really appreciated.


On Jul 8, 7:09&#2013266080;am, "mary27" <66.maryam@n_o_s_p_a_m.gmail.com> wrote:
> Hi, I am having a project where I have to open a EMG signal from muscles in > matlab and use to it find a few parameters. I'm a beginner in matlab so I > apologize if my questions might sound too simple. > first, the file for my signal is a .mat file. I know how to load it in > matlab but how can I open it as a figure? (a plot of my signal) I mean I > wanna see my signal in matlab. > second, I need to find the median frequency for this signal which is in the > time domain itself so it has to turn into freq domain first. I need the > median frequecy for 2 parts of signal, from the beginning to a certain > point in time axis, and then from there to end. How do I do that? > I know about the functions in matlab that take median freq, turn to freq > domain etc but I need the exact code as an example. any help ASAP would be > really appreciated.
Mary27 All of your abswers are in the Matlab help file and manuals. Just type help
On 7/8/2011 5:09 AM, mary27 wrote:
> Hi, I am having a project where I have to open a EMG signal from muscles in > matlab and use to it find a few parameters. I'm a beginner in matlab so I > apologize if my questions might sound too simple. > first, the file for my signal is a .mat file. I know how to load it in > matlab but how can I open it as a figure? (a plot of my signal) I mean I > wanna see my signal in matlab. > second, I need to find the median frequency for this signal which is in the > time domain itself so it has to turn into freq domain first. I need the > median frequecy for 2 parts of signal, from the beginning to a certain > point in time axis, and then from there to end. How do I do that? > I know about the functions in matlab that take median freq, turn to freq > domain etc but I need the exact code as an example. any help ASAP would be > really appreciated. > >
If the signal is loaded then you must know what the name of the array containing the signal is, right? Here's what I do most of the time. Very simple but works for me! let's say that "xoft" is the time signal array "x of t" N=length(xoft) xoff=fft(xoft) plot(1:N,abs(xoff)) The plot will be in terms of N so you will have to translate that to frequencies or be fancier in your plotting. Then, as far as the median goes, compute tot=sum(abs(xoff)) %the total of all the frequency samples totm=tot/2 %half the total of the frequency samples med=0 i=0 while med<totm i=i+1 med=med+abs(xoff(i)) end This will run up until med is greater than totm. Since frequency is discrete, the previous value is likely less than totm. If you want to interpolate frequency to get a "better" estimate of the median frequency using a straight line approximation, then you might do this: fmed = (i-1) + {totm - (med-xoff(i)))/xoff(i) % which can be a noninteger version of the index of the frequency sample. Then you convert that to frequency by multiplying by the (frequency sample interval minus one). Then, you just do this for the samples in both time frames of interest. Fred