Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part Orthogonal vectors Vectors rand u are orthogonal If their Inner product Is

ID: 3567476 • Letter: P

Question

Part Orthogonal vectors Vectors rand u are orthogonal If their Inner product Is O. Write a function import which accepts two row vectors wand u and prints out: Vectors u and v are orthogonal (If u and v are orthogonal) or Vectors u and v are not orthogonal (if v and rare not orthogonal) Function myort has to check the Input arguments and provide the user with the error report If the function is not called according to the following rules: . the function is called with two arguments, . the Input arguments are vectors . the dimensions of the vectors have to be the same. Function myort should perform al operations on individual array elements (Le. do not employ Matlab commands which operate on entire matrices/rows/columns). Part 2: Outer product Write a function myouter which returns the outer product between two vectors. The function should accept two input arguments: the vectors to be multiplied. The function will return the matrix containing the outer product of the two vectors. Requirements. . Your function should perform a operations on Individual array elements (I.e. do not employ Matlab commands which operate on entire matrices/rows/columns). . Your function should determine all necessary vector and matrix sizes. . The size of the output matrix will be determined by the order of the Input arguments. regardless of whether the Input arguments are row or column sectors. The length of the first input vector determines the number of rows in the output vector and the length of the second input vector determines the number of columns In the output matrix. . Your function has to check the input arguments and provide the user with the error report If the function Is not called according to the following rides. - the function Is called with two arguments. - the input arguments we vectors.

Explanation / Answer

Part 1:

function [y]=myort(a,b)
if nargin==2
[m n]=size(a);
[s t]=size(b);
if m==s && n==t
y=zeros(m,n);
for i=1:m
for j=1:n
y(i,j)=a(i,j)*b(i,j);
end
end
else
disp('vectors are not of same dimension')
end

else
disp('there are not 2 arguments as required.')
end
end

part 2:

function [y]=myouter(a,b)
if nargin==2
[m,n]=size(a);
[t s]=size(b);
if n==t
y=zeros(m,s);
for i=1:m
for j=1:s
for k=1:t
y(i,j)=y(i,j)+a(i,k)*b(k,j);
end
end
end
else
disp('dimension mismatch')
end
else
disp('there are not 2 arguments as required.')
end
end