inner product of two vectors

Show
3 older comments

David Young
on 3 Feb 2012

I think it would be helpful if you specified whether the vectors are row vectors, column vectors, or whether they can be an arbitrary mixture. The test suite only has row vectors, but this makes it rather trivial.

Kuifeng
on 4 Apr 2012

If the x and y vectors could be row and column vectors, then bsxfun(@times, x, y) does a better job

Nicholas Howe
on 13 Apr 2012

Test set should include some column vectors.

Rik
on 15 Aug 2013

if you make the example-function "y = fcn(x,y)
z = x*y", please make sure matlab at least handles it; "z = fcn(x,y)
z = x*y" would be preferred =)

Jerivington
on 30 May 2016

This function already exists, look up the dot function

Jihye Sofia Seo
on 8 Feb 2017 at 22:06

In the given code snippet, make some changes to correct the function definition. (The first line)

1 Comment

Jess Stuart
on 7 Feb 2017 at 21:11

Nice little bug in there.

1 Comment

Daniel
on 4 Aug 2016

This is correct. What am I missing?

1 Comment

Jerivington
on 30 May 2016

eazy eazy

3 Comments

Daniel Pereira
on 16 Apr 2013

Why is this smaller than just x*y'?

Carlos Adrian Vargas Aguilera
on 1 Jul 2013

NOt just that, his output is y instead of z!! jajaj...

Mineralter
on 30 Sep 2013

That is the matrix attribute!

1 Comment

Harish Maradana
on 23 Nov 2012

i wrote solution like below
z = sum(x.*y);
it is working on my laptop but in cody show incorrect tell me why

3 Comments

Bryce
on 2 Feb 2012

Hmmm, description is a little confusing. Is length(x) always = length(y)? Are they nx1 or 1xn? Anyhow, I submitted several possible solutions (e.g. z = x'*y, z = sum(x.*y)) all of which failed the test suite ... but they work fine on my machine!

David Young
on 3 Feb 2012

Note that the output variable in the pattern is y, not z.

Stephen
on 1 Mar 2012

ha, yeah. thanks for commenting about that. I didn't see it either.

**Tags**

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
2 players like this problem

2 players like this problem