Borrar filtros
Borrar filtros

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 visualizaciones (últimos 30 días)
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 comentarios
Kagiso Solomon
Kagiso Solomon el 12 de Abr. de 2020
Can I have a code showing how test for a matrix if is a square and a diagonally dominant
Image Analyst
Image Analyst el 12 de Abr. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 15 de Mzo. de 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);

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by