Standard deviation in 3D array from 1st to nth number array
Ältere Kommentare anzeigen
Hello I am trying to calculate residual noise from auditory brainstem responses (ABR).
The 3D array that I'm working in is in the size [2 x 493 x 6000] double which is a reflection of [Nchannels x Ntime x Nepochs].
I have 2 recording channels and each channel consists of 493 time data points and there are 6000 trials (or epochs).
Will call our 3D array ABR.
To calculate residual noise I have to:
- calculate the std of the data points (in rows) from the 1st data point of epoch no.1 (which is given by ABR(:,1,1)) to the last data point of epoch no. X (which is given by ABR(:, end, X)).
- The issue that I'm facing is how to specify calculation of std from 1st epoch to nth epoch.
- I've tried std(ABR,0,2,[ABR(:,1,1), ABR(:,end,1)]); but this is not the answer.
- I need to calcuate 6000 of these in the following format...
- std(ABR,0,2,[ABR(:,1,1), ABR(:,end,1)]);
- std(ABR,0,2,[ABR(:,1,1), ABR(:,end,2)]);
- std(ABR,0,2,[ABR(:,1,1), ABR(:,end,3)]);
- std(ABR,0,2,[ABR(:,1,1), ABR(:,end,4)]);
- std(ABR,0,2,[ABR(:,1,1), ABR(:,end,5)]); ... and so on until the last last number becomes 6000.
- In this case ABR is the data set, 0 is the weighting, 2 means calculation in rows and [] specifies what arrays (or epochs) to calculate std from.
This is what I am tryin to do graphically - using excel.
As you can see each std data point is the std result of all the epochs upto and including the position of the std.

What is the best way to do this?
6 Kommentare
It sounds like you want the std of the second dimension, right?
data = rand(2, 493, 6000);
sd = squeeze(std(data, [], 2));
size(sd)
MinChul Park
am 22 Jun. 2022
Bearbeitet: MinChul Park
am 22 Jun. 2022
MinChul Park
am 22 Jun. 2022
Bearbeitet: MinChul Park
am 22 Jun. 2022
You're getting that error because you're not indexing R correctly. The output of your std line will be a column vector. Here's how to correctly index that:
data = rand(6, 493, 6000);
RN = zeros(size(data,[1,3]));
for i = 1 : size(data,3)
RN(:,i) = std(data(:, :, 1:i), 0, [2,3]);
end
size(RN)
BTW, great methods image! 🙂
MinChul Park
am 22 Jun. 2022
Adam Danz
am 23 Jun. 2022
Glad it worked out! I'll move my comment to the answers section so your quesitons is moved from the unanswered questions queue.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
