Using Matlab; Complete the implementation of the compArray function, which class
ID: 3686759 • Letter: U
Question
Using Matlab;
Complete the implementation of the compArray function, which classifies a pair of arrays (supplied as input variables) as being not equal or equal.
Input variables:
Output variables:
Notes:
If two arrays have different dimensions, they are by definition unequal.
Two arrays of the same size are equal if and only if the corresponding elements at each position in the respective arrays are equal.
The result returned must be logical (true or false), rather than numeric.
This question can easily be completed without the use of loops.
You must not use any of the following Matlab built-in functions in your solution: isequal, isequaln.
a – An arbitrary numeric scalar, vector or matrix. b – An arbitrary numeric scalar, vector or matrix.Explanation / Answer
clear
A = input('Enter matrix coordinates between square brackets seperating with semicolon, like[1 2 3;2 3 4] ')
B = input('Enter matrix coordinates between square brackets seperating with semicolon, like[1 2 ;2 3 ;3 5 ] ')
[Arow,Acol] = size(A)
[Brow,Bcol] = size(B)
function [output] = TLU(Arow,Acol,Brow,Bcol)
if Arow == Brow
if Acol == Bcol
output = false
else
output = true
end
result = output
if result == true
disp(' Matrix A and B are eual')
elseif result == false
disp('Matrix A and B are Unequal')
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.