A triangular creation in a matrix with the rest zeros
Afficher commentaires plus anciens
I want to write a code which does the following:
Say its input is 'n = 12' to create a matrix arranged triangularly with the rest zeros (Only use loop), for example:
% code
Input: n = 12
Output: mat = [1 0 0 0
2 3 0 0
4 5 6 0
7 8 9 10
11 12 0 0]
Thank you
4 commentaires
Jan
le 20 Mai 2018
The shape of the non-zero value is not triangular here.
The question sounds like a homework. The forum will not solve it, but if you ask a specific question and post, what you have done so far, you will get assistance here for sure.
Emilia
le 20 Mai 2018
dpb
le 20 Mai 2018
What if you were to start with an array of the proper final size containing (let me guess...) zeros, maybe?
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!