How to add a condition in programming coding ?
Mostrar comentarios más antiguos
for v=1:j
simdone = 1;
row = 1;
while (simdone == 1)
if ((Co1ap1{v}(row,i+1) <= Co1ap1{v}(row+1,i+1)) && (Co1ap1{v}(row,i+2) > Co1ap1{v}(row+1,i+2) ))
row = row + 1;
else
Co1ap1{v}(row+1,:) = []; % delete row if condition does not match #here i want to make changes ,i want to keep the all row values ,before if the condition doesnot match then it was deleting the row but now i want to keep the rows not delete the rows
end
if (row == size((Co1ap1{v}),1))
simdone = 0; % break the while loop if index is out of bound
end
end
disp(Co1ap1{v})
end
i+1 is the column number .
before when i was doing the sorting that time if any rows values does not match my if condition then i was removing that rows from my metrix ,but now i want to keep that rows at the end of my metrix ,like no rows should be delete i want to keep my metrix size same .But the metrix row's will follow the condition and then they will be in a metrix.
AS a example
A= [12 20 ; 14 16; 16 22; 18 10; 13 12 ;20 5]
after running the above matlab code the result
A=[12 20;14 16;18 10;20 5]
but now i want to keep the other solutions also at the end with my result , don't want to delete them from my solution set
Like
A=[12 20;14 16;18 10;20 5; 16 22;13 12]
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!