Problem 135. Inner product of two vectors
Solution Stats
Problem Comments
-
10 Comments
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.
If the x and y vectors could be row and column vectors, then bsxfun(@times, x, y) does a better job
Test set should include some column vectors.
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 =)
This function already exists, look up the dot function
In the given code snippet, make some changes to correct the function definition. (The first line)
Tricky on the variable to return... not sure if it was for teaching how-to-debug purposes.
funny, after all.
Remember to edit the return variable (change it from y to z)
LOOK FOR 'y' IN-LINE 1
CHANGE IT TO 'z'!!!!!!!!!!
love it
Solution Comments
Show commentsProblem Recent Solvers10216
Suggested Problems
-
Swap the first and last columns
20437 Solvers
-
Get the elements of diagonal and antidiagonal for any m-by-n matrix
476 Solvers
-
Try 1.5.4: Celsius to Fahrenheit
812 Solvers
-
4237 Solvers
-
Find the Oldest Person in a Room
17479 Solvers
More from this Author100
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!