Slow-running code for removing rows
Mostrar comentarios más antiguos
I have a set of code that works, but a part of it runs very slowly. Basically I'm trying to remove zero-only rows from two matrixes, and I'm able to tell that both have an empty row if the first element in one matrix is zero. Here's the actual code:
for a=1:numberofrows
if slopes(a,1)==0
slopes(a,:)=[];
switchingtimes(a,:)=[];
end
end
I'd try to do a nonzeros function and then a reshape function, but sometimes slopes have a zero or two at the end of a column.
Is there any way to speed up this code?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!