help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deleting rows in matrices


From: davidg
Subject: Re: Deleting rows in matrices
Date: Tue, 13 Sep 2011 12:46:32 +0200
User-agent: Internet Messaging Program (IMP) 3.2.8

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) = [];


reply via email to

[Prev in Thread] Current Thread [Next in Thread]