12 February 2008

Behold! Look upon my works of these past two days, ye Mighty, and despair!

And MWT said:

for j=1:length(SCSlat)-1
while SCSsortmatrix(k,1)==SCSsortmatrix(k+1,1)
&& SCSsortmatrix(k,2)==SCSsortmatrix(k+1,2)
if bindex(end) ~=k
bindex=[bindex k];

... And There Was Light.

Disclaimer: code doesn't really produce light. It won't cause despair, either. It actually doesn't do anything of any interest to anyone but me (and possibly my boss). But I wrote it all by myself!


Eric said...

Okay, I gots to know...

What does it do?

Nathan said...

Can you please put up the posts that are gonna confuse the shit out of me closer to mid-day?

MWT said...

Nathan: Where's the fun in that? :)

Eric: It makes an index for bin averaging purposes. Basically, I have a many-rowed, three column table of numbers, where the first two columns are longitude and latitude. I needed to find all the spots where the longitude/latitude changed to a different one. Sometimes this was after one row, sometimes it was after several, so it wasn't as simple as "every x number rows = a new bin." So what that loop does is find all the spots where it changes, then save them to bindex.

The script then continues on, using bindex to say "average this group of numbers together, then this group, then this group..." It's written in Matlab. The ultimate purpose of the whole script is to reduce resolution of some boat data so that I can match it up with data from some satellites (which is at 1km resolution). So I have to round off a ton of decimal places from the boat's longitude/latitude and average stuff together.

Random Michelle K said...

Songratulations on whipping that code into submission!

Tom said...

Cool! I'm reminded of a machine code bubble sort I put together once. You may have inspired me to make a code post of my own!

What I want to know is what the ~= operation is. I've never seen a tilde as an operator.

MWT said...

It means "is not equal to" in Matlab. Most code languages seem to use "!=" for that.

Also: this isn't the PHP script I was hammering out before (which is done to the point of debug runs now - but then I got sidetracked into the current projects).

Today I'm wrasslin' with IDL (interactive data language), which is an even more arcane, obscure language than Matlab...

Anonymous said...

I haven't wrestled with code in a long while... it's even better for the brain than crosswords or sudoku! Even when I do, outside of html, I'm more of a cookbooker than an original coder.

Congrats on solving the problem.