[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Deleting rows in matrices

**From**: |
Qualitang |

**Subject**: |
Re: Deleting rows in matrices |

**Date**: |
Tue, 13 Sep 2011 19:20:29 +0800 |

You, my good sir, are a legend! Thanks a million!
I knew it had to something simple!
Matty.
On Tue, Sep 13, 2011 at 6:46 PM, <address@hidden> wrote:
>* Quoting Qualitang <address@hidden>:*
>
>*> Hi,*
>*>*
>*> I am having (another!) problem on a seemingly innocuous task. Say I*
>*> have many (le x 1) matrices, A, B, C, ......, all of the same length*
>*> "le". I want to check each of the elements in "A", and if an element*
>*> exceeds a limit I want to delete that row, plus the corresponding rows*
>*> in B, C, ...., . Here's my try..*
>*>*
>*> le = length(A)*
>*> for i = 1:le*
>*> if (A(i,1) > 5)*
>*> A(i,:) = [];*
>*> B(i,:) = [];*
>*> C(i,:) = [];*
>*> .....*
>*> endif*
>*> endfor*
>*>*
>*> But I keep getting errors that say the index exceeds the matrix*
>*> dimension - I understand why, it's obvious, but I can't think of*
>*> another method to do this!*
>*>*
>*> Any help is appreciated.*
>*>*
>
>* This will delete all elements in A greater than 5, and the corresponding*
>* elements in B and C:*
>
>* C(A > 5) = [];*
>* B(A > 5) = [];*
>* A(A > 5) = [];*
>