Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Making a square matrix from two vector
Replies: 22   Last Post: Mar 19, 2013 12:37 AM

 Messages: [ Previous | Next ]
 Barry Shaw Posts: 32 Registered: 2/16/12
Re: Making a square matrix from two vector
Posted: Feb 8, 2013 11:55 AM

"Jerry " <jerrycholo@gmail.com> wrote in message <kf36cg\$6vt\$1@newscl01ah.mathworks.com>...
> Hello,
>
> "a" is a vector (size 1-by-11) and "b" is also a vector (size 11-by-1), in that the first number of these two vectors is the same so "a1"="b1".
>
> I would like to create a square matrix (size of this matrix is 11-by-11), from these two vectors in that "a" is the first row of this matrix and "b" is the first column of this matrix. In fact, I am going to use this function [F = (a + b) + (a * b)] to fill out the rest of this matrix. So, the shape of matrix would be in this way:
>
> a1=b1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11
> b2 b2a2 b2a3 b2a4 b2a5.............................................
> b3 b3a2 .......................................................................
> b4 .................................................................................
> b5 .................................................................................
> b6 .................................................................................
> b7 .................................................................................
> b8 .................................................................................
> b9 .................................................................................
> b10 ..................................................................................
> b11 .............................................................................b11a11
>
> Thanks,
> Jerry
>

If you expand this to 11x11 I tihnk this is what you want to do?

>> a = [1 2 3 4];
b = [1 2 4 5];
c = ones(4,4);
c(1,:) = a; c(:,1) = b;
for i = 2 : 4
for j = 2 : 4
c(i,j) = c(i,1) + c (1,j) + c(i,1) * c (1,j);
end
end
>> c

c =

1 2 3 4
2 8 11 14
4 14 19 24
5 17 23 29

Date Subject Author
2/8/13 Jerry
2/8/13 Barry Shaw
2/8/13 dpb
2/8/13 james bejon
2/9/13 Bruno Luong
2/9/13 james bejon
2/9/13 Bruno Luong
2/12/13 james bejon
2/12/13 Steven Lord
2/12/13 Bruno Luong
2/12/13 dpb
2/12/13 Bruno Luong
2/12/13 dpb
2/13/13 Bruno Luong
2/13/13 dpb
2/14/13 Bruno Luong
2/14/13 dpb
2/14/13 Bruno Luong
2/14/13 dpb
2/14/13 dpb
2/13/13 james bejon
3/18/13 James
3/19/13 Bruno Luong