Write a MATLAB function named dist3 that accepts two lists o

Write a MATLAB function named dist3 that accepts two lists of numbers. Each list contains 3 real numbers that represents the x,y,z coordinates of a point. The function should return a single real number that represents the 3-D distance between the two points.

Hint: norm(v) returns sqrt(sum(abs(v)^2))

Solution

code


function [y] = dist3(list1,list2)

list1=[1,0,3]
list2=[3,5,6]

y=sqrt(sum(abs(list1-list2).^2))

output

Write a MATLAB function named dist3 that accepts two lists of numbers. Each list contains 3 real numbers that represents the x,y,z coordinates of a point. The f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site