Mathlab program solving answr below
Mostrar comentarios más antiguos
I want me to reVerse out put what will Be the math lab program looK Like,
n=5
for i=1:n
for j=1:i
fprintf('%d', i)
end
fprintf('\n')
end
7 comentarios
Steven Lord
el 20 de Ag. de 2022
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
dpb
el 20 de Ag. de 2022
What do you expect output to be? What's the purpose of the second loop over j; nothing in the loop is dependent upon it?
Hakim
el 20 de Ag. de 2022
I generated your output above. Could you write down what you want instead of
122333444455555
?
Hakim
el 20 de Ag. de 2022
Hakim
el 20 de Ag. de 2022
Editada: John D'Errico
el 21 de Ag. de 2022
Respuestas (2)
Jan
el 20 de Ag. de 2022
Maybe you want to replace
for i = 1:n
by
for i = n:-1:1
Torsten
el 20 de Ag. de 2022
Movida: Image Analyst
el 21 de Ag. de 2022
n = 5;
for i=n:-1:1
for j=n:-1:i
fprintf('%d', i)
end
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!