## 12 July 2011

### Behold, Some Code!

Since my life reboot, my leet code skillz have gone to whole new levels. Here's a representation of the kinds of things I've been doing for the past three months:

```s = 1; %blort-cell counter
interpnum = cell(1,6);
for t = {East_u, North_v, Vert_w, VelError, Mag, DIR}
blort = t{1};
k = 1; %within blort-cell counter
for i = 1:length(SerYear)
while isnan(blort(i, m))
if m > 1
m = m - 1;
else
break
end
end
while isnan(blort(i, n))
if n < SerBins(end)
n = n + 1;
else
break
end
end
interpnum{s}(k, 1) = i;
if n - m < 5 && ~isnan(blort(i, m)) && ~isnan(blort(i, n))
interpnum{s}(k, 3) = interp1([m n], [blort(i, m) blort(i, n)], badeast(j));
elseif n - m < 5 && isnan(blort(i, m)) && ~isnan(blort(i, n))
interpnum{s}(k, 3) = blort(i, n);
elseif n - m < 5 && ~isnan(blort(i, m)) && isnan(blort(i, n))
interpnum{s}(k, 3) = blort(i, m);
else
interpnum{s}(k, 3) = NaN;
end
k = k + 1;
end
end
clear i blort k
s = s+1;
end
clear s t interpnum
```

It looks at a big block of numbers, one row at a time, and interpolates for any missing values - assuming that there are no more than four missing in a row (in the row). It does this for six individual same-sized blocks.

It's in Matlab. There might actually be a simpler way to do this, but if so I don't know about it. (Obviously.) The fun part is: it only took me two days to work all that out. Leet skillz progress! :D

Nathan said...

I'll trust you that it does what you say it does, but I like it because it's full of "blort".

MWT said...

Yes, that's one of my favorite parts too. :D

Carol Elaine said...