The above is using MatLab , I\'m just having difficulty formatting my functions
ID: 3143443 • Letter: T
Question
The above is using MatLab , I'm just having difficulty formatting my functions correctly.
Thanks in advance
Write a function called matrix Threshold which takes a matrix and a threshold value as inputs as shown below. function [diagonalSum, B] = matrixThreshold (A, threshold) The function produces 2 outputs: = 1. diagonalSum: is the sum of values along the diagonal axis of the matrix A 2. B: is a matrix which has the same size as the matrix A and values 0 corresponding for values less than threshold and values 1 corresponding for values greater than threshold in the matrix AExplanation / Answer
function [diagonalSum,B] = matrixThreshold(A,threshold)
[n,n] = size(A) ;
diagonalSum =0;
for i= 1:n
diagonalSum = diagonalSum + A(i,i);
end
diagonalSum
B= zeros(n,n) ;
for i= 1:n
for j = 1 :n
if A(i,j) > threshold
B(i,j) = 1 ;
end
end
end
B
Please don't forget to rate positively if you found this response helpful.
Feel free to comment on the answer if some part is not clear or you would like to be elaborated upon.
Thanks and have a good day!
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.