Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Dataset find and replace problem
Date: Tue, 18 Aug 2009 22:50:17 +0000 (UTC)
Organization: Penson Financial Services
Lines: 33
Message-ID: <h6fb79$dpn$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1250635817 14135 172.30.248.38 (18 Aug 2009 22:50:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 18 Aug 2009 22:50:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 967726
Xref: news.mathworks.com comp.soft-sys.matlab:564311


I have a dataset array named "sortBA" with three columns and lots of rows (500K+).

I have shown the first twenty rows below:

disp(sortBA(1:20,{'timemilli','cmeB','cmeA'}))

    timemilli        cmeB      cmeA  
    1247146199971    1.3986    1.3989
    1247146199981         0         0
    1247146200001         0         0
    1247146200043         0         0
    1247146200044         0         0
    1247146200049         0         0
    1247146200056         0         0
    1247146200061         0         0
    1247146200081         0         0
    1247146200091         0         0
    1247146200145    1.3986    1.3989
    1247146200188         0         0
    1247146200215         0         0
    1247146200229         0         0
    1247146200250    1.3986    1.3989
    1247146200266    1.3987     1.399
    1247146200290         0         0
    1247146200299    1.3987    1.3989
    1247146200302         0         0
    1247146200303    1.3986     1.399

I need to do a form of "sample and hold" in engineering terms. I want to see if a cell of column "cmeB" or a cell of column  "cmeA" contains a zero.  If it contains a zero I want to replace the zero with the most recent previous nonzero cells value in that column and continue down the rows until I reach the length of the variable "sortBA".  

I have tried everything I can find to do this without luck.

Any help will be greatly appreciated....