how to find average values of answers

2 vues (au cours des 30 derniers jours)
Ali Noori
Ali Noori le 21 Août 2015
Commenté : Ali Noori le 21 Août 2015
%For example, if you write this code for a=1:5; b = 2*a + 1 end the answers are >> b =
3
b =
5
b =
7
b =
9
b =
11
I want to calculate the mean values for these answers
b average = (3 + 5+ 7+ 9+11) / 5 = 7

Réponse acceptée

Purushottama Rao
Purushottama Rao le 21 Août 2015
b=zeros(1,5)
for a=1:5
b(a)=2*a+1;
end
k=mean(b);
  2 commentaires
Purushottama Rao
Purushottama Rao le 21 Août 2015
If you want to diplay every time avg, move mean commnd inside the for loop
Ali Noori
Ali Noori le 21 Août 2015
ok thanks, but ur code will give vector answer for each value of b

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB 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