From: William on
I am trying to create a matrix which is 10x10. The first row should go 1:10, the first column should go from 1:10 (downward), and a diagonal 1:10.

I have it seperated as

A = 1:10
A'
B = diag(A)

how would i combine these matricies so i wouldnt still get a 10x10 matrix?
From: us on
"William " <william.baxter(a)oit.edu> wrote in message <i0drdh$r7l$1(a)fred.mathworks.com>...
> I am trying to create a matrix which is 10x10. The first row should go 1:10, the first column should go from 1:10 (downward), and a diagonal 1:10.
>
> I have it seperated as
>
> A = 1:10
> A'
> B = diag(A)
>
> how would i combine these matricies so i wouldnt still get a 10x10 matrix?

one of the many solutions

rc=1:4;
m=diag(rc);
m(1,:)=rc;
m(:,1)=rc;
disp(m);
%{
1 2 3 4
2 2 0 0
3 0 3 0
4 0 0 4
%}

us