Calculate average of multiple matrices by reading an m.file
3 views (last 30 days)
Show older comments
Samira on 1 Apr 2013
I'm having difficulty in calculating the mean of multiple matrices. I know how to calculate the mean, I have tried to use mean(match,3) in 3 dimension , but it does not give me the mean of all my matrices by columns If I calculate my mean in the while loop, it creates a mean for every matrix, and if I do it outside the while loop, it does it only for the last matrix.
For example while(reading file) ...
if(some conditions) continue
match= strcmp('Hello', out)//compares script with the word hello and outputs a logical array of 1s and 0s
match=[1 0 0 0 0 0] match=[0 0 1 0 0 0] match=[0 0 1 0 0 0]
I want the mean to be M=[1/3 0 2/3 0 0 0]
Do I need to use a for loop? Because it seems to be a much longer process to use a for loop to get the mean, but I do not see how else I could do this.
ChristianW on 1 Apr 2013
k = 0;
while (reading file) ...
k = k+1;
match(k,:) = strcmp('Hello', out)
M = mean(match)
More Answers (0)
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!