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일

1 개 추천

P=diag(ones(6,1)./s)
Or
P=diag(diag(P)./s)

추가 답변 (2개)

Thorsten
Thorsten 2017년 4월 7일
편집: Thorsten 2017년 4월 7일

0 개 추천

P = diag(1./s);
Andrei Bobrov
Andrei Bobrov 2017년 4월 7일
편집: Andrei Bobrov 2017년 4월 7일

0 개 추천

P_out = P./s;
or just
P = eye(6)./s;

댓글 수: 1

Muhendisleksi
Muhendisleksi 2017년 4월 7일
"Error using ./ Matrix dimensions must agree."
Gave the error

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2017년 4월 7일

댓글:

2017년 4월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by