Azzera filtri
Azzera filtri

How to check if my array is square with if and else loops?

3 visualizzazioni (ultimi 30 giorni)
A = [1 -2 1;
0 2 -8;
-4 5 9]
How can I check if this array is a square array using an if-else loop?

Risposta accettata

Chunru
Chunru il 4 Mag 2022
A = [1 -2 1;
0 2 -8;
-4 5 9]
A = 3×3
1 -2 1 0 2 -8 -4 5 9
if ndims(A)==2 && (size(A,1)==size(A,2))
disp("A is Square")
end
A is Square

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by