Effacer les filtres
Effacer les filtres

Add two rows in a matrix with new datas

1 vue (au cours des 30 derniers jours)
Frederike Petersen
Frederike Petersen le 6 Oct 2021
I have a pascal triangle matrix pascal(10) = E. Now I have to calculate the mean and the standard deviation of each column of E. The results have to insert as row 6&7 in Matrix E. (At the end the matrix should have [12 10]).
Thanks for your advices!

Réponse acceptée

C B
C B le 6 Oct 2021
Modifié(e) : C B le 6 Oct 2021
you can do this in below way
E = pascal(10);
k = 5;
E = [E(1:k,:); std(E); E(k+1:end,:)];
k = 6;
E = [E(1:k,:); mean(E); E(k+1:end,:)];
  1 commentaire
Frederike Petersen
Frederike Petersen le 6 Oct 2021
Thanks for your response!! :)

Connectez-vous pour commenter.

Plus de réponses (1)

KSSV
KSSV le 6 Oct 2021
E = pascal(10) ;
iwant = [E ; mean(E) ; std(E)]
iwant = 12×10
1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 10 1 3 6 10 15 21 28 36 45 55 1 4 10 20 35 56 84 120 165 220 1 5 15 35 70 126 210 330 495 715 1 6 21 56 126 252 462 792 1287 2002 1 7 28 84 210 462 924 1716 3003 5005 1 8 36 120 330 792 1716 3432 6435 11440 1 9 45 165 495 1287 3003 6435 12870 24310 1 10 55 220 715 2002 5005 11440 24310 48620
  2 commentaires
C B
C B le 6 Oct 2021
I think he want to insert at 6th and 7th row
Frederike Petersen
Frederike Petersen le 6 Oct 2021
thank you!

Connectez-vous pour commenter.

Catégories

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