How can I simplify/vectorize this nested loop version of pascals triangle?
古いコメントを表示
%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 件のコメント
Stephen23
2018 年 6 月 12 日
@Mark Nelson: is there a specific problem with using a loop?
Mark Nelson
2018 年 6 月 12 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!