I'm having a divide problem in matrices

1 次查看(过去 30 天)
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]

采纳的回答

KSSV
KSSV 2017-4-7
编辑:KSSV 2017-4-7
P=diag(ones(6,1)./s)
Or
P=diag(diag(P)./s)

更多回答(2 个)

Thorsten
Thorsten 2017-4-7
编辑:Thorsten 2017-4-7
P = diag(1./s);

Andrei Bobrov
Andrei Bobrov 2017-4-7
编辑:Andrei Bobrov 2017-4-7
P_out = P./s;
or just
P = eye(6)./s;

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by