for loop and else-if-elseif loo
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i would like to create an matrix(m,n) using for loop and else-if-elseif
- ask user to input m,n
- in the matrix:the value of the element in the first row is the number of the column.the vaue of the element in the first column is the number of the row.the rest of element are equal to the sum of the element above them and the element in the left.
i get this
m=input('number of rows')
n=input('number of column')
a=ones(m,n)
for i=2:m
for j=2:n
a(i,j)=a(i-1,j)+a(i,j-1)
end
end
my problem is concerning the elemt in the first row and column
1 Commento
Walter Roberson
il 25 Nov 2012
Please read the guide to tags and retag this question; see http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags
Risposte (1)
Vedere anche
Categorie
Scopri di più su Structures 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!