The Euclidean norm of an ndimensional vector is defined as x
The Euclidean norm of an n-dimensional vector is defined as ||x|| = Squareroot_k = 1^n x_k^2. Write a Mat lab function compute_Euclidean_norm.m that computes the norm (2), for an arbitrary input vector x. The function should be in the following form function [z] = compute_Euclidean_norm(x)
Solution
% matlab code
function [z] = computeEuclideannorm(x)
s = x.^2;
result = sum(s);
z = sqrt(result);
end
x = input(\"Enter vector: \");
disp(\"Euclidean norm: \");
disp(computeEuclideannorm(x));
%{
output:
Enter vector: [1 2 3 4 5]
Euclidean norm:
7.4162
%}
