what's the point of having 3 coordinates given? you're only asking for the distance between Z and A, right?
You need x,y and z to to get the distance metric in 3D space. But you can reduce the problem to just 3 values by taking the differences between x values and y values and then just taking the 3rd element of z. So there is unnecessary padding in the vectors and you could reduce them all to 3 scalars. Essentially the problem boils down to: sqrt(x^2 + y^2 + z^2).
looks like after you changed the test suite, it worked out anyway. thanks!
Your solution is the best and yes I did alter/correct the test suite. Thanks.
To repeat bmtran's question: Does B have anything to do with the problem?
B is a red herring. I originally conceived the problem in 2D and then extended it to 3D. So you really only need A and Z vectors. However, B can still be used but this creates a more complex solution which you don't want. Sorry if you felt misled, this was my first attempt at trying to upload an interesting problem that was hopefully not too difficult to solve. :)
Project Euler: Problem 2, Sum of even Fibonacci
Who knows the last digit of pi?
Wrapping the Tower of Pisa
Given area find sides
Side of a rhombus
Is A the inverse of B?
Solve the set of simultaneous linear equations
What is the distance from point P(x,y) to the line Ax + By + C = 0?
Find the definite integral of various linear functions
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office