Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: delete entire column

$
0
0
On 3/16/2013 11:36 AM, dpb wrote:
...

>
> And, of course, you can smoosh the condition into the expression if you
> wish to not create the temporary logical at the expense of some
> complexity in the indexing expression.
>

Or, probably bester ([sic] :) )of choices, use the function I posted
just a few days ago to hid the complexity...

x(~iswithin(x,lo,hi),:)=[];

where lo, hi are your chosen limits and iswithin() is sotoo...

function flg=iswithin(x,lo,hi)
   flg= (x>=lo) & (x<=hi);


NB: here the ~ operator to reverse the logic to select those that are
outside the bounds you to remove. Or, of course, you could write the
same equivalently as saving the desired rows instead of removing the
undesirables...

x=x(iswithin(x,lo,hi),:);

I've not compared; you could try timing on realistic arrays to see if it
makes any significant difference depending on which way you go...

--

Viewing all articles
Browse latest Browse all 19628

Trending Articles