How to do I get the standard deviation from an eeg input signal in SImulink?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tania Akhtar
am 15 Mai 2024
Bearbeitet: Tania Akhtar
am 15 Mai 2024
Hello I'm trying to make a function block that calculates standard deviation of the signal, as the standard deviation blocks do not give me the standard deviation of the SIMULINK signal (they either give me 0 or say it needs discrete values). However that doesnt work either, is there a way for me to get the standard deviationl? I want to equal the signal to 0 if the sdv is higher than a certain value.
I've tried the following but it isn't working.
function y = fcn(u)
std(u)
y = std(u)
end
my input is an eeg signal taken from the workspace using "from workspace" (simin)
2 Kommentare
Sam Chak
am 15 Mai 2024
Hi, could you provide a sample of the EEG data for testing if the algorithm for standard deviation works as expected?
Akzeptierte Antwort
Sam Chak
am 15 Mai 2024
Since you're able to extract the EEG signal from the CHB-MIT Dataset and load it into the Workspace, it would be more efficient to directly compute the standard deviation in MATLAB. The standard deviation is a statistical measure used to quantify the amount of variation in a set of data values. It does not inherently depend on time.
However, Simulink executes the graphical block diagramming at each simulation time step. Thus, instead of using the 'simin' block, which includes a time stamp on the data values, you can feed the chunk of EEG data directly into the 'Constant' block and then connect it to the 'Standard Deviation' block or the 'Mean' block. This way, the statistical measures will be calculated accurately.
Solution in MATLAB:
input = [0 -79.9023199023199
0.00390625000000000 -66.6178266178266
0.00781250000000000 -56.8498168498169
0.0117187500000000 -49.4261294261294
0.0156250000000000 -38.0952380952381
0.0195312500000000 -27.5457875457875
0.0234375000000000 -17.7777777777778
0.0273437500000000 -11.1355311355311
0.0312500000000000 -11.1355311355311];
[S, M] = std(input(:,2))
%% For Simulink
t = input(:,1);
y = input(:,2);
simin.time = t;
simin.signals.values = [y];
simin.signals.dimensions = 1;
Solution in Simulink:

2 Kommentare
Sam Chak
am 15 Mai 2024
You're welcome! To display the signal, you have a couple of options. You can use either the Scope block or the Display block, depending on which one suits your specific application better.
On another note, if you're not familiar with the If-Action block or find it challenging to work with, an alternative approach would be to use the MATLAB Function block. This allows you to code the If-Else statement directly, and it might provide a clearer and more intuitive solution for the coder.
Weitere Antworten (1)
Walter Roberson
am 15 Mai 2024
The instantaneous standard deviation of a signal is 0.
Standard deviation normally depends on a complete population -- a complete set of discrete signals.
It might possibly make sense to create a "moving standard deviation" -- but you would have to be moving over a fixed time interval (rather than a fixed number of samples)... it would get a bit tricky to implement for continuous signals.
0 Kommentare
Siehe auch
Kategorien
Mehr zu EEG/MEG/ECoG finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!