title: Discover if a Simulink signal is a bus programmatically
body: <p>I am using MATLAB 2013b, and I am attempting to write a script that will automatically wire up ToWorkspace blocks to a selected set of signals.</p>
  
  <p>I can handle finding/getting handles to the signals, adding the blocks, setting the variable names, and so forth. What I want to do, however, is programmatically discover if a selected signal is a scalar, array, or bus signal. This way, I can reshape arrays to be 1D (so that they concatenate the way I want) and break down bus signals into their individual elements.</p>
  
  <p>I attempted the fix posted at <a href="https://stackoverflow.com/questions/5992774/see-if-a-signal-originates-from-a-bus-in-simulink">See if a signal originates from a bus in Simulink</a> but with no luck. I'm betting that the post is old enough that the proposed fix didn't work in the version of MATLAB I'm attempting to use.</p>
  
  <p>I know the answer involves compiling the model or updating the model with a certain command, but I am stuck. Help please!</p>
  
  <p>Here's what I tried to do, based on the link above:</p>
  
  <pre><code>function usedNames = addToWorkspaceBlock( signal, usedNames )
     % Recursively add whatever blocks are necessary to break down the signal
     % into raw bus elements or reshaped arrays and output them that way
  
     switch upper( get(signal,'CompiledBusType') )
        case 'NOT_BUS'
           % Will add the reshape block and ToWorkspace block here, saving
           % the name of the ToWorkspace VariableName to usedNames
           keyboard % for debugging
        case {'VIRTUAL_BUS','NON_VIRTUAL_BUS'}
           % Will add the reshape block and ToWorkspace block here, saving
           % the name of the ToWorkspace VariableName to usedNames
           keyboard % for debugging
        otherwise
           error('Unrecognized CompiledBusType %s', get(signal,'CompiledBusType'));
     end
  end
  </code></pre>
  
  <p>The error I get is this: (ignore the line numbers; my <code>addToWorkspaceBlock()</code> function is a subfunction of my main function which handles getting the signals and looping through them)</p>
  
  <pre><code>Error using createToWorkspaceBlocks&gt;addToWorkspaceBlock (line 48)
      line does not have a parameter named 'CompiledBusType'
  
  Error in createToWorkspaceBlocks (line 36)
      usedNames = addToWorkspaceBlock( signals(i), usedNames );
  </code></pre>