Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Binary matrix?
Date: Mon, 22 Oct 2012 11:45:08 +0000 (UTC)
Organization: Xoran Technologies
Lines: 14
Message-ID: <k63bk4$s4i$1@newscl01ah.mathworks.com>
References: <k5vp68$h5o$1@newscl01ah.mathworks.com> <k5vuu0$5ua$1@newscl01ah.mathworks.com> <k613c7$3kt$1@newscl01ah.mathworks.com> <k61he8$j5p$1@newscl01ah.mathworks.com> <k62ic0$6in$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1350906308 28818 172.30.248.45 (22 Oct 2012 11:45:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 22 Oct 2012 11:45:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:781139

"Chuck37" wrote in message <k62ic0$6in$1@newscl01ah.mathworks.com>...
>
> > FREAD let's you read from the file with a 'ubitn' precision type. I've never used it, but I'm guessing that let's you read in individual bits. So if you passed a precision argument of 'ubit1=>uint8', that might do what you want.
> 
> Thanks, but then I'd still be using 8x the memory necessary if I stored every bit using 8 bits.  For an image with millions of pixels, this is significant.
============

Millions of pixels doesn't actually sound all that significant, but regardless, MATLAB gives you no alternative, I'm afraid. It offers no matrix data types that consume less than 1 byte per element. 

Remember what I said, though, about sparse matrices. If your bits are mostly zeros, storing them as type sparse would conserve a lot of memory. 

  help sparse

Or, if they are mostly ones, then not(yourmatrix) would be sparse instead and you could work in terms of that.