How can I simplify/vectorize this nested loop version of pascals triangle?
Afficher commentaires plus anciens
%mypascal
n = input('Enter a value for n: ');
% create matrix using nested loops (programming method)
somemat = ones(n);
for i = 2:n
for j = 2:n
somemat(i,j) = somemat(i-1,j) + somemat(i, j-1);
end
end
2 commentaires
Stephen23
le 12 Juin 2018
@Mark Nelson: is there a specific problem with using a loop?
Mark Nelson
le 12 Juin 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!