I am probably the only person in the world who didn’t know about this trick but I’m so gosh darned thrilled about it that I’m going to share it with you anyway.
WARNING: terrible nerdness ahead, the more sensitive of souls might want to skip this.
I had a 60×1 struct called ‘Trial’ in which I had a parameter (Trial.StatorDyn) that I wanted to couple to a <60×236 double> matrix called ‘Stim’ . I thought I’d be smart and make a second matrix and then add it to Stim.
A = Trial.StatorDyn
Stim = [Stim , A].
This brilliant plan did not work because Trial is a struct;
mood = Argh.
Now I am not one to run for help, I generally sit and glare at my screen, curse a bit and then cry myself to sleep. Luckily I had gone to a colleague before this mechanism kicked in and he showed me how mind-runningly easy the solution was. The answer is (insert pause for suspense); brackets.
Yep just plain old brackets. Or if you want to be fancy about it you can use vertcat.
A = vertcat(Trial.StatorDyn); or even just A = [Trial.StatorDyn];
Stim = [Stim,A];
Right. Sigh. Bang Head. Start Again.