Help making a matrix table
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Could someone please help me make a matrix.
I need code that would make an NxN matrix with the pattern of:
if N=4
[1 1 1 1;
0 1 1 1;
0 0 1 1;
0 0 0 1]
0 comentarios
Respuestas (2)
John D'Errico
el 9 de Dic. de 2022
Can you create a matrix of all ones?
Consider the function triu. Read the help. Look at the examples.
0 comentarios
David
el 9 de Dic. de 2022
Movida: Image Analyst
el 10 de Dic. de 2022
Hi! Got your back, i'm leaving a code that can do that.
Also, you can consider making a ones matrix with 'ones(N)', and getting the upper triangular with 'triu(M)'.
Hope you find this useful! <3
% With 'N' as the dimention of a square matrix.
M = zeros(N);
for i = 1 : N
for j = i : N
M(i,j) = 1;
end
end
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!