How to vectorize this loop? Subsequental subtraction of columns within a matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Senaasa
am 3 Jun. 2014
Kommentiert: Andrei Bobrov
am 3 Jun. 2014
I'm trying to vectorize the following loop:
a=rand(1000,100);
j=1;
k=2;
tic
for i=1:50;
b(:,i)=a(:,j)-a(:,k);
j=j+1;
k=k+1'
end
toc
Is there any easier way to subsequently subtract an entire column from the previous column within a matrix?
Thanks, Charles
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!