Effacer les filtres
Effacer les filtres

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 vues (au cours des 30 derniers jours)
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 commentaires
Kagiso Solomon
Kagiso Solomon le 12 Avr 2020
Can I have a code showing how test for a matrix if is a square and a diagonally dominant
Image Analyst
Image Analyst le 12 Avr 2020
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.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 15 Mar 2015
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);

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by