For loops for printing pattern in matlab
Mostrar comentarios más antiguos
I am quite new to matlab and just like in python I want to get familiar with loops in matlab therefore I was trying to print the following pattern.
#####
####
###
##
#
When I am using the disp() function everything is being printed on the same line.
Respuesta aceptada
Más respuestas (1)
str = '#' ;
for i = 5:-1:1
s = repmat(str,1,i) ;
fprintf('%s\n',s) ;
fprintf('\n')
end
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!