flip a matrix using loops
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hi,
im tring to flip a matrix usind withot the flip function
for ex:
[1 3 -2; -4 4 8; 7 -1 3] will cange to [7 -1 3; -4 4 8; 1 3 -2]
my script is
outFlip(i,:)= inMatrix(size(inMatrix,1)+1-i,:);
0 Kommentare
Antworten (2)
madhan ravi
am 9 Dez. 2018
matrix=randi([0,4],2);
outFlip=zeros(size(matrix,1),size(matrix,2));
for i= 1:size(matrix,1)
for j=1:size(matrix,2)
outFlip(j,i)=matrix(i,j); % just swap the indices
end
end
2 Kommentare
madhan ravi
am 9 Dez. 2018
ok then:
matrix=[1 3 -2; -4 4 8; 7 -1 3];
ctr=1;
outFlip=zeros(size(matrix,1),size(matrix,2));
for i=size(matrix,1):-1:1
outFlip(i,:)=matrix(ctr,:); % just swap the indices
ctr=ctr+1;
end
outFlip
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!