how velocize it? (vectorize it)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
a=magic(8)
b=[1 3 2 4 5 5 8 3] % (b is always >0)
[~,c]=size(a);
B=a;
for i=1:c
if b(i)>1
B(1:b(i)-1,i)=0;
end
end
B
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 8 Okt. 2023
a=magic(8)
b=[1 3 2 4 5 5 8 3] % (b is always >0)
B = a.* ((1:size(a,1))' >= b)
1 Kommentar
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!