|
"Hermano Cappa" <cappasteven@gmail.com> wrote in message <hosodj$k6q$1@fred.mathworks.com>...
> Hi,
>
> I want to write a easy method for a simple matrix operation but I don't know how to start.
>
> I have two matrices A and B:
>
> A = [0 0.5; 1 1.5; 2 2.5]; % number of rows can change, columns is 2
> B = [10; 20]; % 2 x 1 matrix
>
> I want combine them to a matrix C with the result:
>
> C = [0 10; 0.5 20; 1 10; 1.5 20; 2 10; 2.5 20];
>
> How can I do this?
>
> Thanks
Hi Hermano,
one of many ways:
a = A';
a = a(:);
b = repmat(B, [length(a)/2 1])
C = [a b]
hth
kinor
|