A Function to Un-Nest Nested Structures in MATLAB

So I’m flying back from Shanghai right now, (youalreadyknow it’s business class) and I decided to business-expense-splurge for the in-flight wifi, which is about as fast as a snail in the process of peacefully passing away. This means the only scrap of entertainment I can garner from my laptop is writing code in MATLAB. Writing fuckaround code in a pretend programming language in a rickety IDE has a provided surprising source of succor; if you were here you’d know it too because you’d notice I have been sitting FOR HOURS WITHOUT MY SEATBELT ON because I was simply too enraptured by the alternating tides of hate and happiness that MATLAB so easily exerts on the user.

Basically, I’m working on a GUI that allows a user to programmatically  create test limits for test data, while also allowing the user to efficiently adjust the limits where our absurd test data manages to invalidate centuries of statistical knowledge. This requires allowing the user to load a specific test from within an absurdly packaged data file which comes from a test system written by someone who clearly much prefers obfuscating and hiding things over effective data collection WHICH in turn means deeply and variably nested structures. Like 400-megabyte-CSV, stuck-in-limbo-with-Leonardio-DiCaprio, booger-that-you-can-feel-but-after-several-embarrassing-red-lights-you-cannot-remove levels deep.

Therefore, after careful perusal of mathworks, I wrote the following code. It uses recursion to return an array of strings describing each and every branch of a struct, down to the twig. It is surely my greatest accomplishment thus far.

function allfields=fieldnamesr(struct);
% FIELDNAMESR recursively explores the depths of nested structs To find all
% possible branches
%      fuck yeah recursion
fields=fieldnames(struct); %are there any field names?
idx=1; %increment variable
for i=1:1:size(fields,1) %for all field names
    if isstruct(struct.(fields{i})) %see if that field name itself is a structure 
        temp=structRecurrr(struct.(fields{i})); %if also structure, then we must go deeper!
        for j=1:1:length(temp) %for all returned values 
        allfields{idx,1}=sprintf('%s.%s',fields{i},temp{j}); %return a string containing returned values
        idx=idx+1; %increment
        allfields{idx}=fields{i}; %if field name not struct, then we are at bottom level
        idx=idx+1; %increment



Classic bro-split. With some things mixed up/distributed.


The idea is to cut effectively. The metabolic shift when cutting can reduce caloric deprivation efficacy for people with naturally slow metabolisms, while the energy deficiency can hurt those looking to preserve lean mass, especially for people with fast metabolisms, and people coming off of bulks. The plan is made for my friend (Aquadman) who is looking mainly to have visible abs, so the preservation of lean mass is somewhat secondary, but the theory is compound lifts for energy output and physiological stimulus, with a rotating high-intensity finish in order to add some spice.

Personally, while cutting, compounds and higher weekly lift frequency helps preserve lean mass. It’s completely anecdotal, but I’d guess the consistent stimulus keeps a muscle group from being in ignored by the body, while the compound lifts helps maintain a more anabolic hormonal balance.



This plan was developed for Ironvlad the Giggly and the Philibuster, two fairly light individuals who are training up for Muay Thai. The idea behind this is a simplistic 3-day/week periodized program to gain lean mass to develop functional strength for Muay Thai using barbells and dumbbells only–it is assumed that other more specific training will be done in the scope of the Muay Thai classes. The two individuals it’s intended for need to move up a weight class, so the idea is to split between large compound lifts in a strength rep/set scheme to build power and explosiveness and large compounds with accessories in a  hypertrophic rep/set schemes to help build lean mass. The mesocycle structure throws in some extra MUSCLE CONFUSION by changing movements and modulating intensity and volume through out the cycle. The gradual ratcheting of volume/intensity through the cycle, besides being a mainstay of periodization, is intended to take advantage of the bulk.


Essentially, the 1RM are establish on Week 0, which sets the weights for the next few weeks. Then a 6 week periodized mesocycle follows, with each cycle ending by re-establishing a (hopefully) higher 1RM. Obviously, the %1RM numbers and rep/set structures are guidelines, as the math they are based on is fairly generalized, and one sees a lot of variation day-to-day and person-to-person in response to volume/weight/bulking etc. And besides, sometimes your friends are watching and the cute chick you were staring at is vaguely looking in your direction wondering which of the sweaty, grunting, gym nerds is making so many noises and the random song that came on right before your set drops super hard and you deadlift your current 5RM for an easy 12 and you walk away like a light-headed, red-faced, veiny and skinless gorilla, so never let a prescribed rep number tell you what to do.

The structure of the lifts is 2 main movements, meant to be done at the rep and set and %1RM determined by the week number. This is then followed by 2 accessory super sets, which don’t really need to follow the mesocycle, though the recommendation is 4 x 6-10. The 2 accessory lifts vary through the week, and there’s a decoder ring which includes 2 versions for each accessory superset; the idea is to alternate between the  x.1 and x.2 versions one week to the next.

There’s also a little calculation section on the right which recommends the weekly intake, and daily recommended intake as per Ironvlad The Giggly’s BMR, activity, desired gains, desired time etc. Everything that’s green text in a green box is for user input, in order to calculate necessary intake.

Click here to download:




IMG_2730.JPGMuch like worried parents will fuss over a child before sending them off into the world, I fidgeted over the details of this lil guy, attempting to delay the inevitable departure, filled with pride and worry at the rigors he’ll face out in the real world. Unlike most worried parents, I eventually said “fuck it,” and dropped this fucker off at the local Fedex, to be shipped cross country in a large cardboard box.


The details were particularly sweat-able on this build, as this was essentially the third iteration on the concept, starting with a beast of the beats that went to Keith, and then a semi-pro configuration that went nowhere. Here are the vague details of the build:



Obviously, the first detail to isolate is the Lego theme. Legos, by the way, are a fairly mediocre permanent construction material. Turns out the 10-micron precision makes them fairly expensive from a cost/volume stand point (a small enclosure requires a lot of legos). Had my little siblings help me build lego boxes to compare the looks. Turns out rainbow is a crowd favorite


Fast forward a few days, after much designing, some deliberation, and then cutting, I’ve got a wood box to match the lego box. I believe I designed for 4L internal volume for each NS3 driver, which, in retrospect, I feel was too much. However, once the wood is cut…alea acta est. I went for a seamless miter approach on this build, to avoid the ugly “end-grain” of the birch plywood. I wrapped the grain around the “depth” of the box, but the grain of the “face” does not flow into the edges. So far I haven’t figured out a solution to this that works out in our boring 3 dimensional Euclidean / Newtonian universe.


Here we can see the translucence of the 3d prints, pre assembly. Originally, I had not planned for there to be a VU lightstrip in this build, but then I realized that since I built all the electronics off of the wood box, fitting them into the lego box, which had 5/6 faces constrained already, would be extremely difficult. At this point, I also realized I miscalculated the amount of space wires take up. Medusa rears her ugly cable management head yet again.


Now you see what I mean.


Analog signal processor demonstrating that I am the particular type of person that loves neat things but does not love making things neat, and so I live in a constant torment of my own devising. I chose a scheme that allows for a bass shelf at lower volumes, but flattens the EQ towards higher volumes—it’s essentially a loudness compensation circuit, except that since I have no reference for the actual loudness of the output (due to lack of information about source gain, listener position). I call it the “party” compensation circuit, because while one might enjoy deep sonorous extension at lower listening levels, once your friends roll through, 14 beers deep each, you’re cranking that fucking volume knob. And while the NS3’s have a lot of allowable excursion before crashing, the garbage bass lines that litter the hip hop soundscape are essentially glorified sine waves that will fuck your shit up. The obvious and simple solution to this is a simple dynamic gain-tied or signal-adaptive high-pass for excursion limiting, or a multi-band compressor. I leave these endeavors as an exercise to the reader until I have the time to implement them on the next build.IMG_2409.JPG

Pre-wood finishing. After disliking the gumminess and amber tint of marine spar varnish, I chose to use tung oil to bring out the figure. Then I sealed the box+3d printed parts with epoxy (bar top) for strength/durability, and finally, for UV protection and hardness, I finished with a clear gloss polycrylic. Here’s what it looks like finished:



So for  the KrumpKanon I’m going with the W5-1138SMF, and for Keith’s, the W6 version of the same driver. Why? Because it has the excursion, Fs, and general specs to have solid bandwidth and linearity at loud volumes. Unfortunately, if you look at the models:



The yellow line represents the optimal ported design, while the blue is the optimal 8″ Dayton Audio PR design. The vented design is more efficient, has higher bandwidth, and requires less box volume. However, for a 4″x2.5″ port, opening I’d need 36 inches of port to get the 12L box resonating at 36 Hz. That’s absurd, and what’s more absurd is that at 50W, the airspeed would be ~40 m/s. That’s 90 mph, and the air has to move 90 mph through a folded port 3ft long. I have low expectations for the laminarity of the air flow in that scenario, but an educated guess tells me it would sound like an elephant farting through a muffler.

PR’s it is. With dual 8 inch passive radiators, I could be pretty near the vented design, but a) that’s a ridiculous amount of radiator area for a 5 inch  area, b) that’s 2x the cost, machining, surface area dedicated to the radiator, and c) trying to fit two 8-inch radiators, a 5-inch woofer, and 2 full ranges onto the front of the boom box would be ridiculous. Why not throw them on the back? Well, then the front will look stupid, barren. I want the raw visual and auditory power of a fat fucking 8″ blasting you in the face. But fitting 2 8’s on to the front of a reasonably sized boom box (using the esteemed [boombox name to go here once I find my notes] as a template) would be geometrically dubious.

So at the sacrifice of about 1/3 of an octave of bass, I’m going with a single 8. I hate leaving bass on the table, especially when it’s easy, efficient bass, but given the constraints and my desire for a simplistic design…it’ll have to do. Additionally, and this is the most important part, but, if you look at an analysis of the most popular music being played these days, there’s  little content beneath 40 Hz, and therefore, little need for sound below 40. So I guess 40 Hz it is, and we’ll hope it sounds good. There’s only way to find out.