필터 지우기
필터 지우기

Write a function file that takes as input a matrix A, and tests whether or not the matrix is (a) square, and (b) diagonally dominant, reporting the answers on the screen. Show that your code is correct by testing it for the matrix in question 2, as w

조회 수: 3 (최근 30일)
Write a function file that takes as input a matrix A, and tests whether or not the matrix is (a) square, and (b) diagonally dominant, reporting the answers on the screen. Show that your code is correct by testing it for the matrix in question 2, as well as for cases where the matrix is not diagonally dominant, and not square.
  댓글 수: 3
Kagiso Solomon
Kagiso Solomon 2020년 4월 12일
Can I have a code showing how test for a matrix if is a square and a diagonally dominant
Image Analyst
Image Analyst 2020년 4월 12일
Kasigo: Try this:
m = zeros(3, 3, 3, 3);
if length(unique(size(m))) == 1 % Works for any number of dimensions of matrix (2-D, 3-D, 4-D, etc.)
fprintf('Array is square.\n');
else
fprintf('Array is NOT square.\n');
end
Surely a smart guy like you can take the definition from Wikipedia: Diagonally_dominant_matrix and do the code.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2015년 3월 15일
Functions that may help you: size(), warndlg(), sprintf(), inputdlg(), fprintf(), helpdlg().
Hints:
message = sprintf('The value is %f', theValue);
uiwait(helpdlg(message));
errorMessage = sprintf('This array is not square!\nIt has %d rows and %d columns', rows, columns);
uiwait(warndlg(errorMessage));
fprintf('%s\n', errorMessage);

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by