Mean value of each row
3 views (last 30 days)
Show older comments
Hi everyone, so I have a 5287x1103 (double) matrix of precipitation data. I basically wanna compute a vector with the mean of each row:
- load('mymatrix');
- mean_H = mean ('mymatrix',2);
At least this is what should do the trick in my opinion. However it only computes a single value (i.e. the total mean)...
can anyone help me out? Thank you very much, Oliver
0 Comments
Answers (1)
Guillaume
on 22 Jan 2015
Surely, you meant:
mean_H = mean(mymatrix, 2); %note the absence of '
Otherwise you're computing the mean of ascii values of the string 'mymatrix'
7 Comments
Image Analyst
on 22 Jan 2015
Oliver's reply moved from an "Answer" to a comment here:
Hmm...the error "Argument must contain a string" pops up. Sorry I'm a complete newbie. Is there something wrong with the imported data format? cheers
Image Analyst
on 22 Jan 2015
Then you should read this where it explains that we need the complete error message - ALL THE RED TEXT - so we know what line of code you're talking about. In the meantime, try this:
fullFileName = fullfile(pwd, 'mymatrix.mat');
if exist(fullFileName, 'file')
storedStructure = load(fullFileName)
mymatrix = storedStructure.mymatrix;
mean_H = mean(mymatrix, 2); % Means across columns.
else
warningMessage = sprintf('The file does not exist:\n%s', fullFileName);
uiwait(warndlg(warningMessage));
mean_H = [];
end
See Also
Categories
Find more on Data Type Conversion 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!