Mean value of each row

3 views (last 30 days)
Oliver Weiss
Oliver Weiss on 22 Jan 2015
Commented: Image Analyst on 22 Jan 2015
Hi everyone, so I have a 5287x1103 (double) matrix of precipitation data. I basically wanna compute a vector with the mean of each row:
  1. load('mymatrix');
  2. 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

Answers (1)

Guillaume
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
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
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

Sign in to comment.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!