how to store the matrix from for loop?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
JAGADEESH JAGA
el 1 de Feb. de 2017
Comentada: JAGADEESH JAGA
el 3 de Feb. de 2017
m=3;
A=[ 1 1 0];
B=[0 1 0];
D=B-A;
d1=m*A;
for X=0:1:m
C=d1+D*X
end
0 comentarios
Respuesta aceptada
KSSV
el 1 de Feb. de 2017
m=3;
A=[ 1 1 0];
B=[0 1 0];
D=B-A;
d1=m*A;
C = zeros(m+1,length(d1)) ;
for X=1:1:m+1
C(X,:)=d1+D*X ;
end
Más respuestas (1)
Andrei Bobrov
el 1 de Feb. de 2017
Editada: Andrei Bobrov
el 2 de Feb. de 2017
m=3;
A=[ 1 1 0];
B=[0 1 0];
D=B-A;
d1=m*A;
C = d1 + (0:m)'*D; % R2016b and later
C = bsxfun(@plus,d1,(0:m)'*D); % R2016a and earlier
2 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!