How can I make my values become positive?

44 vues (au cours des 30 derniers jours)
Miriã  Gollmann
Miriã Gollmann le 16 Juin 2018
Commenté : Alfonso le 17 Juin 2018
I have array values and I need to know which command I should use to make my values become positive and how can I find the mean of all array values?
Thanks.

Réponse acceptée

Alfonso
Alfonso le 16 Juin 2018
Modifié(e) : Alfonso le 16 Juin 2018
% Example: 3x2 array
myArray = [-1,-2;-3,2;-3,-4];
% Make all values in array positive
myArray = abs(myArray);
% Mean value of array
m = mean(myArray) % m returns a row vector where each column is the mean of each column of your array
% If you want a single mean value for all values of your array
% concatenate values in a single row
array = [myArray(:,1); myArray(:,2)];
m_all = mean(array);
  3 commentaires
Miriã  Gollmann
Miriã Gollmann le 17 Juin 2018
I really got it with this command. I produced two means, one of wind velocity on vector U and other of wind velocity on vector V. Now, do you know how can I put this values in a cell array?
Alfonso
Alfonso le 17 Juin 2018
% Save mean values in cell array
cellArray = {mean_U, mean_V};

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Operators and Elementary Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by