Code covered by the BSD License  

Highlights from
Modeling Flexible Bodies in SimMechanics

image thumbnail
from Modeling Flexible Bodies in SimMechanics by Dallas Kennedy
Technical paper and examples on modeling flexibility in SimMechanics.

paper_plot_position_data( datat , datay , description , whichTime , whichEndTime )
function paper_plot_position_data( datat , datay , description , whichTime , whichEndTime )
% PAPER_PLOT_POSITION_DATA  Helper function to plot deflection
%
% PAPER_PLOT_POSITION_DATA( T , Y , DESCRIPTION ) will plot the data described
% by T and Y. It will also report the results of frequency/steady-state
% analysis.

% Copyright 2006, The MathWorks, Inc.
  
    YDATA = 2;
    DOTITLE = false;
    
    t = datat( : , 1 );
    y = datay( : , YDATA ) * 1e3; % convert to mm
    
    [ period , deflectionMean , deflectionStd ] = ...
        paper_calculate_period( t , y , whichTime , whichEndTime );
    
    figure;
    plot( t, y , 'b-' );
    xlabel( 'Time [sec]' , 'Interpreter' , 'latex' , 'FontSize' , 14 );
    ylabel( '{\em y }-deflection [mm]' , 'Interpreter', 'latex' , 'FontSize' , 14 );
    if DOTITLE
        title( [ 'Deflection of ' description ] , 'FontSize' , 16 );
    end
    
    fprintf( 1 , ...
             '--- MODEL: %s\n' , ...
             description );
    fprintf( 1 , ...
             'Period = %5.3f sec   Frequency = %5.3f Hz\n' , period , 1/period );
    fprintf( 1 , ...
             'Deflection is centered at approximately %5.3f +- %5.3f \n\n' , ...
             deflectionMean , deflectionStd );
    

Contact us at files@mathworks.com