mutiplying vector of different size?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
here is what i got
a=linspace(1,1,4); b=linspace(1,1,20);
when i try c=a*b i get a error message saying " ??? Error using ==>mtimes Inner matrix dimensions must agree."
I know this is because a is 4 columns while b has 20 columns, but I don't know how else to define a and b to allow them to multiply. I am trying to find all possible values of c
Answers (2)
bym
on 27 Nov 2011
is this what you want?
a =
1 2 3 4
b =
Columns 1 through 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Columns 15 through 20
15 16 17 18 19 20
>> a.'*b
ans =
Columns 1 through 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14
2 4 6 8 10 12 14 16 18 20 22 24 26 28
3 6 9 12 15 18 21 24 27 30 33 36 39 42
4 8 12 16 20 24 28 32 36 40 44 48 52 56
Columns 15 through 20
15 16 17 18 19 20
30 32 34 36 38 40
45 48 51 54 57 60
60 64 68 72 76 80
Walter Roberson
on 27 Nov 2011
[A,B] = ndgrid(a,b);
c = A .* B;
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!