a simple substitution problem !

i have a 2x2 matrix
u = [ 10 10 ; 5 5 ] ; for example
how can i use a simple code to transfer it to
u =
[ 0.5 10 ; 5 0.5 ]
i use
subs ( diag(u) , 0.5 );
but it didn't work
please help me with the problem!!!
thank you!

답변 (3개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 19일
편집: Azzi Abdelmalek 2013년 2월 19일

0 개 추천

Edit
u = [ 10 10 ; 5 5 ];
y=u(:);
n=size(u,1);
y((1:n).^2)=0.5;
out=reshape(y,n,n)
José-Luis
José-Luis 2013년 2월 19일

0 개 추천

a = rand(10);
[m n] = size(a);
a(1:m+1:numel(a)) = 0.5;
Andrei Bobrov
Andrei Bobrov 2013년 2월 19일

0 개 추천

a = rand(10);
a(eye(size(a))>0) = 0.5;

카테고리

도움말 센터File Exchange에서 Octave에 대해 자세히 알아보기

제품

태그

질문:

2013년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by