How can i create an n x m matrix that the value of each element is the first row is the number of the column?
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ENRIQUE SANCHEZ
el 26 de Oct. de 2016
Comentada: Rajdip
el 20 de Nov. de 2022
How can I write a program in a script file that creates a n x m matrix that the value of the each element in the first row is the number of the column? The value of each element in the first column is the number of the row. The rest of the elements each has a value equal to the sum of 2 times of the element above it and the element to the left.
0 comentarios
Respuesta aceptada
KSSV
el 26 de Oct. de 2016
clc; clear all ;
n = 5 ;
m = 7 ;
M = zeros(n,m) ;
M(1,:) = 1:m ;
M(:,1) = 1:n ;
for i = 2:n
for j = 2:m
M(i,j) = 2*(M(i-1,j)+M(i,j-1)) ;
end
end
4 comentarios
Diprit
el 20 de Nov. de 2022
clc
n = 3
m = 3
M = zeros(n,m)
M(1,:) = 1:m
M(:,1) = 1:n
for i = 2:n
for j = 2:m
M(i,j) = M(i-1,j)+M(i,j-1)
end
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays 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!