I'm having a divide problem in matrices

1 vue (au cours des 30 derniers jours)
Muhendisleksi
Muhendisleksi le 7 Avr 2017
Commenté : Muhendisleksi le 7 Avr 2017
P =[ 1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1]
s =[0.6500
0.8000
1.0000
1.4000
1.5000
1.9500]
P=diag(eye(6)./s) % I'm getting an error here.
% This is the matrix I want to create.
P= [ 1.5385 0 0 0 0 0
0 1.2500 0 0 0 0
0 0 1.0000 0 0 0
0 0 0 0.7143 0 0
0 0 0 0 0.6667 0
0 0 0 0 0 0.5128]

Réponse acceptée

KSSV
KSSV le 7 Avr 2017
Modifié(e) : KSSV le 7 Avr 2017
P=diag(ones(6,1)./s)
Or
P=diag(diag(P)./s)

Plus de réponses (2)

Thorsten
Thorsten le 7 Avr 2017
Modifié(e) : Thorsten le 7 Avr 2017
P = diag(1./s);

Andrei Bobrov
Andrei Bobrov le 7 Avr 2017
Modifié(e) : Andrei Bobrov le 7 Avr 2017
P_out = P./s;
or just
P = eye(6)./s;
  1 commentaire
Muhendisleksi
Muhendisleksi le 7 Avr 2017
"Error using ./ Matrix dimensions must agree."
Gave the error

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by