Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Indexing a range of array values using a matrix?
Date: Sat, 10 Mar 2012 22:29:11 +0000 (UTC)
Organization: Xoran Technologies
Lines: 25
Message-ID: <jjgkjn$ngt$1@newscl01ah.mathworks.com>
References: <jjgb6e$qfh$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1331418551 24093 172.30.248.47 (10 Mar 2012 22:29:11 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 10 Mar 2012 22:29:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:760568

"Evan Ruzanski" wrote in message <jjgb6e$qfh$1@newscl01ah.mathworks.com>...
> Hello,
> 
> I'm looking to create the following output without using loops. Let's say I have some array of data:
> 
> >> arr = [1 7 3 2 1 5 6 7 8 4]'
> 
> and a matrix that defines a range of indices related to the array:
> 
> >> arrLocs = [2 4;6 9]
> 
> whose first column represents the start values and second column represents the end values of the range to extract from the data array. So using this example I would like to see the following output:
> 
> >> out = [0 0;1 0;1 0;1 0;0 0;0 1;0 1;0 1;0 1;0 0] 
================

I could be missing something obvious, but this makes little sense to me. Your out variable contains lots of zeros even though your input data arr contain none. 


 

> Again, I can do this with loops no problem but I'm trying to avoid loops.
===============

Elaborate on why you're trying to avoid loops. It seems like the logical thing to use.