how to store the matrix from for loop?
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 1 Feb. 2017
Bearbeitet: Andrei Bobrov
am 2 Feb. 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 Kommentare
Stephen23
am 2 Feb. 2017
+1 nice use of MATLAB.
Andrei Bobrov
am 2 Feb. 2017
Thank you Stephen!
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!