error evaluating binary operator

Michael Grossbach michael at grossbach.org
Sat Aug 2 11:23:31 CDT 2008


Emily Moberg wrote:
> Hi!
> I have the following for loop
> [m,o]=size(A)
> for n=1:o
> idx=find(A(:,n)==0);
> if length(idx)>=m*(.7);
> A(:,n)=[];
> endif;
> endfor;
> and I keep getting an error evaluating binary operator '=='  for the 
> idx=find(A(:,n)==0) line. I'm not sure what I'm doing wrong... I'm still 
> rather new at this, so sorry if this is a trivial question!
> Thanks!

Whenever the condition

if length(idx)>=m*(.7)

is met you eliminate the respective column with the command

A(:,n)=[];

but don't change o (the number of columns) accordingly. Hence n takes on 
an illegal value once it reaches beyond the actual size of A.

HTH, Michael


More information about the Help-octave mailing list