MEX files

Locked
Shin Young Hak
Posts: 10
Joined: 06 Jul 2010, 09:00

MEX files

Post by Shin Young Hak » 14 Jul 2010, 04:03

:D Hello all~
I have a question about MEX files document in BCI2000 wiki

in the function of mem.
[spectrum, frequencies] = mem(signal, parms);

I don't know how is the form of input parms.
I have tried many forms of parms but error massage is occurred.

for example,

parms = [parameters.ModelOrder.NumericValue, parameters.FirstBinCenter.NumericValue,parameters.LastBinCenter.NumericValue,parameters.BinWidth.NumericValue,parameters.EvaluationsPerBin.NumericValue];

[spectrum, frequency]=mem(signal, parms);

error message is this
??? Error using ==> mem
Expected real double input signal -- The mem command estimates a power spectrum
using Burg's MEM algorithm.
The calling syntax is:
[spectrum, frequencies] = mem(signal, parms)
with <signal> and <spectrum> having dimensions values x channels, and
with <parms> being a vector of parameter values:
model order,
first bin center,
last bin center,
bin width,
evaluations per bin,
detrend option (optional, 0: none, 1: mean, 2: linear; defaults to none),
frequency (optional, defaults to 1)

Error in ==> test at 26[spectrum, frequency]=mem(signal, parms);


please give me a reply

thank you

Young Hak Shin

jawilson
Posts: 109
Joined: 28 Feb 2005, 16:31

Post by jawilson » 14 Jul 2010, 10:25

It is hard to tell what is happening, but it appears the signal might not be in the matlab "double" format. You can try this:

Code: Select all

signal = double(signal);
[spectrum, frequencies] = mem(signal, parms); 
or this:

Code: Select all

[spectrum, frequencies] = mem(double(signal), parms); 
and it might work.
Adam

Shin Young Hak
Posts: 10
Joined: 06 Jul 2010, 09:00

Post by Shin Young Hak » 16 Jul 2010, 07:36

Thank you for your response
As your mention, i tried like below

parms=[20, 0, 30, 3, 15];
[spectrum, frequency]=mem(double(signal), parms);

but i have another error message
??? Error using ==> mem
Bin width must be between 0 and half the sampling rate.

Error in ==> test at 26
[spectrum, frequency]=mem(double(signal), parms);


I set the BinWidth to 3. and sampling rate is 256, block size is 32.
This BinWidth is between 0 and half the sampling rate.
I don't know what is the problem.
please help me

Thank you

Shin Young Hak

jawilson
Posts: 109
Joined: 28 Feb 2005, 16:31

Post by jawilson » 16 Jul 2010, 08:11

Ok, I see the problem. You need to pass the Frequency parameter, which is optional. If you do not pass it, then it defaults to 1, and all of your values would then need to be scaled accordingly, e.g., 0.0 <= BinWidth < 0.5, and so on. This parameter lets the program know what the sample rate is. So, you could use:

Code: Select all

parms = [parameters.ModelOrder.NumericValue, parameters.FirstBinCenter.NumericValue, parameters.LastBinCenter.NumericValue, parameters.BinWidth.NumericValue, parameters.EvaluationsPerBin.NumericValue, 1, parameters.SamplingRate.NumericValue];
I added the "1" so that the mean is removed from the signal (you can also try 2), and then the sampling rate.

This should work...

Locked

Who is online

Users browsing this forum: No registered users and 0 guests