How do I make this function work for any matrix size?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kylenino Espinas
am 23 Okt. 2020
Beantwortet: Walter Roberson
am 24 Okt. 2020
%How do I change this function so that it works for matrices of any size?
function [B] = Matrices(matrice)
B = matrice;
B(1,1) = 0;
B(1,2) = 0;
B(1,3) = 0;
B(2,2) = 0;
B(2,3) = 0;
B(3,3) = 0;
end
%So that calling this
[B] = Matrices([1 2 3; 4 5 6; 7 8 9])
%Will return
B =
0 0 0
4 0 0
7 8 0
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Okt. 2020
function B = Matrices(matrice)
B = tril(matrice,-1);
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Elementary Math finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!